arnaucube
arnaucube/decentralized-blogging-platformPublic Self-hosted repository
decentralized-blogging-platform/webapp/views/post/post.js
webapp/views/post/post.jsRaw
 1'use strict';
 2
 3angular.module('app.post', ['ngRoute'])
 4
 5    .config(['$routeProvider', function($routeProvider) {
 6        $routeProvider.when('/post/:postid', {
 7            templateUrl: 'views/post/post.html',
 8            controller: 'PostCtrl'
 9        });
10    }])
11
12    .controller('PostCtrl', function($scope, $rootScope, $http, $routeParams) {
13        $scope.post = {};
14        $scope.user = {};
15        $http.get(apiurl + 'post/' + $routeParams.postid)
16            .then(function(data) {
17                console.log('data success');
18                console.log(data);
19                $scope.post = data.data;
20                $scope.user = $scope.post.user;
21            }, function(data) {
22                console.log('no user');
23            });
24    });