Last active
August 29, 2015 14:05
-
-
Save fizerkhan/3e7b4447f421de8ce3fa to your computer and use it in GitHub Desktop.
Angular Controller and Factory.
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
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