Created
January 5, 2013 19:44
-
-
Save andyczerwonka/4463263 to your computer and use it in GitHub Desktop.
How would get gain access to successF and errorF?
This file contains hidden or 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
| service.factory('userService', [ | |
| '$http', | |
| function($http) { | |
| return { | |
| name : 'User Service', | |
| request : {}, | |
| successF : {}, | |
| errorF : {}, | |
| login : function(user) { | |
| this.successF = {}; | |
| this.errorF = {}; | |
| this.request = { | |
| method : 'POST', | |
| url : '/api/login', | |
| data : user | |
| }; | |
| return this; | |
| }, | |
| success : function(func) { | |
| this.successF = func; | |
| return this; | |
| }, | |
| error : function(func) { | |
| this.errorF = func; | |
| return this; | |
| }, | |
| go : function() { | |
| console.log('Executing ' + this.request); | |
| $http(this.request).success(function(data, status, headers, config) { | |
| successF(data, status, headers, config); | |
| }).error(function(data, status, headers, config) { | |
| errorF(data, status, headers, config); | |
| }); | |
| } | |
| }; | |
| } ]); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how I'm trying to call the service...