Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. app.controller('FeedController', function() {
  2. this.posts = followedPosts;
  3. });
  4.  
  5. var followedPosts = [
  6. {
  7. id: 35,
  8. },
  9. ];
  10.  
  11. <div ng-controller="FeedController as feed" ng-include="'/static/angular/phone-list/phone-list.template.html'">
  12. <li ng-repeat="post in feed.posts>{{post}}</li>
  13. </div>
  14.  
  15. app.controller('FeedController', function($http) {
  16. this.posts = [];
  17.  
  18. var data = $.param({
  19. grant_type: 'password',
  20. username: 'test',
  21. password: 'test',
  22. client_id:'test',
  23. client_secret:'test',
  24. });
  25.  
  26. var config = {
  27. headers : {
  28. 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
  29. }
  30. }
  31.  
  32. $http.post('/o/token/', data, config)
  33. .success(function (data, status, headers, config) {
  34. access_token = data['access_token'];
  35. console.log(access_token);
  36.  
  37. $http({method: 'GET', url: 'api/posts/', headers: {'Authorization': 'Bearer '+access_token}}).then(function(response) {
  38. this.posts = response.data;
  39.  
  40. });
  41.  
  42. })
  43. .error(function (data, status, header, config) {
  44. $scope.ResponseDetails = "Data: " + data +
  45. "<hr />status: " + status +
  46. "<hr />headers: " + header +
  47. "<hr />config: " + config;
  48. });
  49.  
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement