Created
January 1, 2015 13:32
-
-
Save wcadap/c38125eb4eb911ed2058 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
contactApp.factory('contactDataService', ['$http', '$q', | |
function ($http, $q) { | |
var _contacts = []; | |
var _getContacts = function () { | |
var deferred = $q.defer(); | |
var controllerQuery = "contact/GetContacts"; | |
$http.get(controllerQuery) | |
.then(function (result) { | |
// Successful | |
angular.copy(result.data, _contacts); | |
deferred.resolve(); | |
}, | |
function (error) { | |
// Error | |
deferred.reject(); | |
}); | |
return deferred.promise; | |
} | |
//Expose methods and fields through revealing pattern | |
return { | |
contacts: _contacts, | |
getContacts: _getContacts | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment