From: Gustavo Martin Morcuende Date: Fri, 21 Aug 2015 14:45:36 +0000 (+0200) Subject: showcase: welcome route (routing per module instead of a global routing) X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=d53b6c3871a5cb75f9b85e9aaa94da98d50ece1d;p=JavaScriptForFun showcase: welcome route (routing per module instead of a global routing) --- diff --git a/angularjs/showcase/src/showcase/app/app.config.js b/angularjs/showcase/src/showcase/app/app.config.js deleted file mode 100644 index 3a8490c..0000000 --- a/angularjs/showcase/src/showcase/app/app.config.js +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('app') - .config([ - '$stateProvider', - '$urlRouterProvider', - - function($stateProvider, $urlRouterProvider) { - var welcome = { - abstract: false, - url: '/welcome', - templateUrl: 'app/welcome/welcome.html' - }; - - $urlRouterProvider.otherwise('welcome'); - $stateProvider.state('welcome', welcome); - } - ]); -}()); diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.controller.spec.js b/angularjs/showcase/src/showcase/app/welcome/welcome.controller.spec.js index 2a4e603..b86f10d 100644 --- a/angularjs/showcase/src/showcase/app/welcome/welcome.controller.spec.js +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.controller.spec.js @@ -1,7 +1,8 @@ describe('app.welcome', function() { 'use strict'; - var controller, scope; + var controller; + var scope; beforeEach(function() { module('app.welcome'); diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.module.js b/angularjs/showcase/src/showcase/app/welcome/welcome.module.js index 32786f8..31702c1 100644 --- a/angularjs/showcase/src/showcase/app/welcome/welcome.module.js +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.module.js @@ -1,6 +1,8 @@ (function() { 'use strict'; - angular.module('app.welcome', []); + angular.module('app.welcome', [ + 'app.core' + ]); })(); diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.route.js b/angularjs/showcase/src/showcase/app/welcome/welcome.route.js new file mode 100644 index 0000000..eaba189 --- /dev/null +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.route.js @@ -0,0 +1,30 @@ +(function() { + 'use strict'; + + angular + .module('app.welcome') + .config(configure); + + /** + * @ngdoc object + * @name app.welcome.$configure + * + * @requires $stateProvider + * @requires $urlRouterProvider + * + * @description + * Router configuration for welcome application. + */ + /* @ngInject */ + function configure($stateProvider, $urlRouterProvider) { + var state = 'welcome'; + var config = { + abstract: false, + url: '/welcome', + templateUrl: 'app/welcome/welcome.html' + }; + + $urlRouterProvider.otherwise(state); + $stateProvider.state(state, config); + } +}()); diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.route.spec.js b/angularjs/showcase/src/showcase/app/welcome/welcome.route.spec.js new file mode 100644 index 0000000..4db3d48 --- /dev/null +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.route.spec.js @@ -0,0 +1,24 @@ +describe('app.welcome', function() { + 'use strict'; + + describe('state', function() { + var view = { + welcome: 'app/welcome/welcome.html' + }; + var $state; + + beforeEach(function() { + module('app.welcome'); + + inject(function(_$state_) { + $state = _$state_; + }); + }); + + it('should map /welcome route to welcome View template', function() { + expect($state.get('welcome').templateUrl). toEqual(view.welcome); + }); + + }); + +}); diff --git a/angularjs/showcase/src/showcase/index.html b/angularjs/showcase/src/showcase/index.html index 2fca851..b3c5607 100644 --- a/angularjs/showcase/src/showcase/index.html +++ b/angularjs/showcase/src/showcase/index.html @@ -52,10 +52,10 @@ + - - +