controller.js
angular.module("exampleApp", [])
    .constant("baseUrl", "/products/")
    .controller("defaultCtrl", function ($scope, $http, baseUrl) {
        $scope.updateProduct = function (product) {
            ****product.$save();**  // How this works?**
            $scope.displayMode = "list";
        }
           $scope.editOrCreateProduct = function (product) {
                $scope.currentProduct = product ? product : {};
                $scope.displayMode = "edit";
           }

    });

products.html
<div class="panel-body">
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th>Name</th>
                <th>Category</th>
                <th class="text-right">Price</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="item in products">
                <td>{{item.name}}</td>
                <td>{{item.category}}</td>
                <td class="text-right">{{item.price | currency}}</td>
                <td class="text-center">
                    <button class="btn btn-xs btn-primary" 
ng-click="deleteProduct(item)">
                        Delete
                    </button>
                    <button class="btn btn-xs btn-primary" 
ng-click="editOrCreateProduct(item)">
                        Edit
                    </button>
                </td>
            </tr>
        </tbody>
    </table>
    <div>
        <button class="btn btn-primary" 
ng-click="listProducts()">Refresh</button>
        <button class="btn btn-primary" 
ng-click="editOrCreateProduct()">New</button>
    </div>
    </div




here in update method product.$save(); used 
How this works with sevice url ?
How it could interact with server.?
to get the data from server we used 
$scope.productsResource = $resource(baseUrl + ":id", { id: "@id" });
someObject = productResource.get(url,params);
How to see the data returned by server?
What is the @id concept ?
Expected how $save works and without url?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to