Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fizerkhan/3e7b4447f421de8ce3fa to your computer and use it in GitHub Desktop.
Save fizerkhan/3e7b4447f421de8ce3fa to your computer and use it in GitHub Desktop.
Angular Controller and Factory.
var myapp = angular.module('myapp', []);
myapp.factory('awesomeService', function($http) {
return {
GetUser: function() {
return $http.get("some url here").then(function(response) {
//Process Stuff Here
return response;
});
},
}
});
myapp.controller('MainCtrl', function($scope, awesomeService) {
awesomeService.getUser().then(function(response){
$scope.user = response;
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment