Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('FeedController', function() {
- this.posts = followedPosts;
- });
- var followedPosts = [
- {
- id: 35,
- },
- ];
- <div ng-controller="FeedController as feed" ng-include="'/static/angular/phone-list/phone-list.template.html'">
- <li ng-repeat="post in feed.posts>{{post}}</li>
- </div>
- app.controller('FeedController', function($http) {
- this.posts = [];
- var data = $.param({
- grant_type: 'password',
- username: 'test',
- password: 'test',
- client_id:'test',
- client_secret:'test',
- });
- var config = {
- headers : {
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
- }
- }
- $http.post('/o/token/', data, config)
- .success(function (data, status, headers, config) {
- access_token = data['access_token'];
- console.log(access_token);
- $http({method: 'GET', url: 'api/posts/', headers: {'Authorization': 'Bearer '+access_token}}).then(function(response) {
- this.posts = response.data;
- });
- })
- .error(function (data, status, header, config) {
- $scope.ResponseDetails = "Data: " + data +
- "<hr />status: " + status +
- "<hr />headers: " + header +
- "<hr />config: " + config;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement