Commit f06fa207eb5ce8ed380eb263c58c7933249e80e5
1 parent
d773bf49
Exists in
master
and in
38 other branches
Migrate to ui-router
Showing
8 changed files
with
48 additions
and
15 deletions
Show diff stats
bower.json
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | "angular-messages": "~1.4.2", |
10 | 10 | "angular-aria": "~1.4.2", |
11 | 11 | "angular-resource": "~1.4.2", |
12 | - "angular-route": "~1.4.2", | |
12 | + "angular-ui-router": "~0.2.15", | |
13 | 13 | "bootstrap-sass": "~3.3.5", |
14 | 14 | "angular-bootstrap": "~0.13.4", |
15 | 15 | "malarkey": "yuanqing/malarkey#~1.3.1", | ... | ... |
src/app/components/noosfero-blocks/main-block/main-block.directive.js
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | .directive('noosferoMainBlock', noosferoMainBlock); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function noosferoMainBlock($log, $routeParams, noosfero) { | |
9 | + function noosferoMainBlock($log, $stateParams, noosfero) { | |
10 | 10 | var directive = { |
11 | 11 | restrict: 'E', |
12 | 12 | templateUrl: 'app/components/noosfero-blocks/main-block/main-block.html', |
... | ... | @@ -24,8 +24,8 @@ |
24 | 24 | /** @ngInject */ |
25 | 25 | function MainBlockController() { |
26 | 26 | var vm = this; |
27 | - $log.log($routeParams.page); | |
28 | - noosfero.articles().get({path: $routeParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { | |
27 | + $log.log($stateParams.page); | |
28 | + noosfero.articles().get({path: $stateParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { | |
29 | 29 | //FIXME |
30 | 30 | vm.article = article.articles[0]; |
31 | 31 | $log.log(vm.article); | ... | ... |
src/app/content-viewer/content-viewer.controller.js
... | ... | @@ -7,16 +7,16 @@ |
7 | 7 | |
8 | 8 | |
9 | 9 | /** @ngInject */ |
10 | - function ContentViewerController($timeout, noosfero, $log, $routeParams) { | |
10 | + function ContentViewerController(noosfero, $log, $stateParams) { | |
11 | 11 | var vm = this; |
12 | 12 | vm.article = null; |
13 | 13 | activate(); |
14 | 14 | |
15 | 15 | function activate() { |
16 | - $log.log($routeParams.page); | |
17 | - noosfero.articles().get({path: $routeParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { | |
16 | + $log.log($stateParams.page); | |
17 | + noosfero.articles().get({path: $stateParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { | |
18 | 18 | //FIXME |
19 | - vm.article = article.articles[0]; | |
19 | + vm.content = article.articles[0]; | |
20 | 20 | }); |
21 | 21 | } |
22 | 22 | } | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +<div class="container"> | |
2 | + | |
3 | + <div> | |
4 | + <acme-navbar></acme-navbar> | |
5 | + </div> | |
6 | + | |
7 | + <div class="row"> | |
8 | + <ng-include ng-repeat="box in vm.owner.boxes | orderBy: vm.boxesOrder" src="'app/views/profile/box.html'"></ng-include> | |
9 | + </div> | |
10 | + | |
11 | +</div> | |
12 | + | |
13 | +{{vm.article}} | ... | ... |
src/app/index.module.js
... | ... | @@ -2,6 +2,6 @@ |
2 | 2 | 'use strict'; |
3 | 3 | |
4 | 4 | angular |
5 | - .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ngRoute', 'ui.bootstrap', 'toastr']); | |
5 | + .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr']); | |
6 | 6 | |
7 | 7 | })(); | ... | ... |
src/app/index.route.js
... | ... | @@ -5,7 +5,18 @@ |
5 | 5 | .module('angular') |
6 | 6 | .config(routeConfig); |
7 | 7 | |
8 | - function routeConfig($routeProvider) { | |
8 | + function routeConfig($stateProvider, $urlRouterProvider) { | |
9 | + $stateProvider | |
10 | + .state('profile', { | |
11 | + url: '/:profile', | |
12 | + templateUrl: 'app/profile/profile.html', | |
13 | + controller: 'ProfileController', | |
14 | + controllerAs: 'vm' | |
15 | + }); | |
16 | + | |
17 | + $urlRouterProvider.otherwise('/'); | |
18 | + | |
19 | + /* | |
9 | 20 | var profileController = { |
10 | 21 | templateUrl: 'app/profile/profile.html', |
11 | 22 | controller: 'ProfileController', |
... | ... | @@ -15,11 +26,20 @@ |
15 | 26 | .when('/profile/:profile', { |
16 | 27 | redirectTo: '/:profile' |
17 | 28 | }) |
18 | - .when('/:profile', profileController) | |
19 | - .when('/:profile/:page*', profileController) | |
29 | + .when('/:profile', { | |
30 | + templateUrl: 'app/profile/profile.html', | |
31 | + controller: 'ProfileController', | |
32 | + controllerAs: 'vm' | |
33 | + }) | |
34 | + .when('/:profile/:page*', { | |
35 | + templateUrl: 'app/content-viewer/page.html', | |
36 | + controller: 'ContentViewerController', | |
37 | + controllerAs: 'vm' | |
38 | + }) | |
20 | 39 | .otherwise({ |
21 | 40 | redirectTo: '/' |
22 | 41 | }); |
42 | + */ | |
23 | 43 | } |
24 | 44 | |
25 | 45 | })(); | ... | ... |
src/app/profile/profile.controller.js
... | ... | @@ -7,13 +7,13 @@ |
7 | 7 | |
8 | 8 | |
9 | 9 | /** @ngInject */ |
10 | - function ProfileController($timeout, noosfero, $log, $routeParams) { | |
10 | + function ProfileController(noosfero, $log, $stateParams) { | |
11 | 11 | var vm = this; |
12 | 12 | vm.boxes = []; |
13 | 13 | activate(); |
14 | 14 | |
15 | 15 | function activate() { |
16 | - noosfero.communities().get({identifier: $routeParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { | |
16 | + noosfero.communities().get({identifier: $stateParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { | |
17 | 17 | $log.log(profile); |
18 | 18 | vm.owner = profile.communities[0]; |
19 | 19 | }); | ... | ... |
src/index.html
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> |
26 | 26 | <![endif]--> |
27 | 27 | |
28 | - <div ng-view></div> | |
28 | + <div ui-view></div> | |
29 | 29 | |
30 | 30 | <!-- build:js(src) scripts/vendor.js --> |
31 | 31 | <!-- bower:js --> | ... | ... |