SHARE
TWEET

Untitled

smiche Oct 3rd, 2016 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. In service:
  2.         function GetCurrent(controllerName) {
  3.             console.log('called by '+controllerName);
  4.             return $http.get('/api/users/current').then(handleSuccess, handleError);
  5.         }
  6.  
  7.         function handleSuccess(res) {
  8.             return $q.resolve(res.data);
  9.         }
  10.        
  11.         function handleError(res) {
  12.             return $q.reject(res.data);
  13.         }
  14. In Controller:
  15.  
  16.         Service.GetCurrent('me')
  17.         .then(function(data){
  18.             console.log(data);
  19.         })
  20.         .catch(function(err){});
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top