Tuesday, January 29, 2013

Angular JS Resource to support Header

I just made a pull request from 1.1.2 which support header parameters in resource actions which very useful for doing authentication.
 https://github.com/angular/angular.js/pull/1906

 Here is the example how to use it


  $scope.signIn = function () {
      Authenticate.signIn(null,null,
          function (data, headers) {
              console.log(headers('x-token'));
              tokenHandler.setToken(headers('x-token'));
          },
          function(data, status, headers, config) {
              console.log('fail');
          },
          { 'Authorization': 'Basic dGVzdGtrMTNssdfdfsgsdfzdC5jb206cGFzc3dvcmQhMQ==' }
      );

===
 And Here is the example to use Token Handler https://gist.github.com/4662548

No comments: