Commit 8700980c53fb6a43163a47ed73ef08c0e4987636
1 parent
f5c8bc74
Exists in
master
and in
38 other branches
Create service for noosfero api
Showing
3 changed files
with
9 additions
and
15 deletions
Show diff stats
src/app/components/noosfero/noosfero.service.js
1 | 1 | (function() { |
2 | 2 | 'use strict'; |
3 | 3 | |
4 | - angular.module('angular').service('noosfero', noosfero); | |
5 | - | |
6 | - function noosfero() { | |
7 | - this.communities = communities; | |
8 | - this.articles = articles; | |
9 | - function communities() { | |
10 | - // return $resource('/api/v1/communities/:id'); | |
11 | - } | |
12 | - function articles() { | |
13 | - // return $resource('/api/v1/articles/:id'); | |
4 | + angular.module('angular').factory('noosfero', function(Restangular) { | |
5 | + return { | |
6 | + communities: Restangular.service('communities') | |
14 | 7 | } |
15 | - } | |
8 | + }); | |
16 | 9 | })(); | ... | ... |
src/app/content-viewer/content-viewer.controller.js
... | ... | @@ -7,13 +7,14 @@ |
7 | 7 | |
8 | 8 | |
9 | 9 | /** @ngInject */ |
10 | - function ContentViewerController(noosfero, $log, $stateParams, Restangular, $state) { | |
10 | + function ContentViewerController(noosfero, $log, $stateParams, $state) { | |
11 | 11 | var vm = this; |
12 | 12 | vm.article = null; |
13 | 13 | activate(); |
14 | 14 | |
15 | 15 | function activate() { |
16 | - Restangular.one('communities', $state.current.data.profile.id).one('articles').get({path: $stateParams.page}).then(function(articles) { | |
16 | + console.log($state.current.data); | |
17 | + noosfero.communities.one($state.current.data.profile.id).one('articles').get({path: $stateParams.page}).then(function(articles) { | |
17 | 18 | $log.log(articles); |
18 | 19 | vm.content = articles.article; |
19 | 20 | }); | ... | ... |
src/app/profile/profile.controller.js
... | ... | @@ -7,13 +7,13 @@ |
7 | 7 | |
8 | 8 | |
9 | 9 | /** @ngInject */ |
10 | - function ProfileController(noosfero, $log, $stateParams, $state, Restangular) { | |
10 | + function ProfileController(noosfero, $log, $stateParams, $state) { | |
11 | 11 | var vm = this; |
12 | 12 | vm.boxes = []; |
13 | 13 | activate(); |
14 | 14 | |
15 | 15 | function activate() { |
16 | - Restangular.one('communities').get({private_token: '1b00325e5f769a0c38550bd35b3f1d64', identifier: $stateParams.profile}).then(function(communities) { | |
16 | + noosfero.communities.one().get({private_token: '1b00325e5f769a0c38550bd35b3f1d64', identifier: $stateParams.profile}).then(function(communities) { | |
17 | 17 | $log.log(communities); |
18 | 18 | vm.owner = communities.communities[0]; |
19 | 19 | $state.current.data.profile = vm.owner; | ... | ... |