Skip to content

Instantly share code, notes, and snippets.

@itswadesh
Last active March 27, 2017 15:17
Show Gist options
  • Save itswadesh/d718415f31abb3a3289f8a2dcdd0045d to your computer and use it in GitHub Desktop.
Save itswadesh/d718415f31abb3a3289f8a2dcdd0045d to your computer and use it in GitHub Desktop.
app.controller('ProductsCtrl', function($scope, Product, ngProgress, toaster) {
$scope.product = new Product();
var refresh = function() {
$scope.products = Product.query();
$scope.product ="";
}
refresh();
$scope.add = function(product) {
Product.save(product,function(product){
refresh();
});
};
$scope.update = function(product) {
product.$update(function(){
refresh();
});
};
$scope.remove = function(product) {
product.$delete(function(){
refresh();
});
};
$scope.edit = function(id) {
$scope.product = Product.get({ id: id });
};
$scope.deselect = function() {
$scope.product = "";
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment