Created
September 5, 2014 12:15
-
-
Save sivaprasadreddy/8a1744e0696fbdaa9375 to your computer and use it in GitHub Desktop.
Contact-Service-Ctrl.js
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
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