blog.directive.js
1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(function() {
'use strict';
angular
.module('angular')
.directive('noosferoBlog', noosferoBlog);
/** @ngInject */
function noosferoBlog() {
var directive = {
restrict: 'E',
templateUrl: 'app/components/noosfero-articles/blog/blog.html',
scope: {
article: '=',
profile: '='
},
controller: BlogController,
controllerAs: 'vm',
bindToController: true
};
return directive;
/** @ngInject */
function BlogController(noosfero) {
var vm = this;
vm.posts = [];
vm.perPage = 3;
vm.currentPage = 1;
vm.loadPage = function() {
noosfero.articles.one(vm.article.id).customGET('children', {
content_type: 'TinyMceArticle',
per_page: vm.perPage,
page: vm.currentPage
}).then(function(response) {
vm.totalPosts = response.headers('total');
vm.posts = response.data.articles;
});
}
vm.loadPage();
}
}
})();