javascript - Pass addl parameter to angularjs promise -
var dologin = function(username, password) { var request = $http({ method: "get", url: 'api/login', params: {}, data: {} }); return request.then(success, error); } function success(response, username) { ... }
if remove username parameter success() method, response gets passed success(), , works fine. specific instance, need pass username (passed dologin) http success callback function. however, promise takes reference function. how pass username fn success()?
you can pass anonymous function success callback:
return request.then(function(data) { success(data, username); }, error);
Comments
Post a Comment