Last active
January 14, 2016 05:11
-
-
Save vinay13/828e7a038eb25bc5344c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.jvandemo.com/how-to-resolve-angularjs-resources-with-ui-router/ | |
.factory('UserService', function ($resource) { | |
var data = $resource('http://jsonplaceholder.typicode.com/users/:user', {user: '@user'}, { | |
update:{ | |
method:'PUT' | |
} | |
}); | |
return data; | |
}); | |
Inside controller(UserService){ | |
UserService.update({user: 1}, {name: 'Saimon', email: '[email protected]'}); | |
} | |
angular.module('demo') | |
.config(['$stateProvider', function ($stateProvider) { | |
$stateProvider | |
.state("customers", { | |
url : "/customers", | |
templateUrl: 'customers.html', | |
resolve: { | |
// A string value resolves to a service | |
customersResource: 'customersResource', | |
// A function value resolves to the return | |
// value of the function | |
customers: function(customersResource){ | |
return customersResource.query(); | |
} | |
}, | |
controller : 'customersCtrl' | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment