Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Contact-Service-Ctrl.js
myApp.service('ContactService', ['$http',function($http){
this.getContacts = function(){
var promise = $http.get('contacts')
.then(function(response){
return response.data;
},function(response){
alert('error');
});
return promise;
}
}
}]);
myApp.controller('ContactController', [ '$scope', 'ContactService', function ($scope, ContactService) {
ContactService.getContacts().then(function(data) {
$scope.contacts = data;
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.