showcase: welcome route (routing per module instead of a global routing)
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Fri, 21 Aug 2015 14:45:36 +0000 (16:45 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Fri, 21 Aug 2015 14:45:36 +0000 (16:45 +0200)
angularjs/showcase/src/showcase/app/app.config.js [deleted file]
angularjs/showcase/src/showcase/app/welcome/welcome.controller.spec.js
angularjs/showcase/src/showcase/app/welcome/welcome.module.js
angularjs/showcase/src/showcase/app/welcome/welcome.route.js [new file with mode: 0644]
angularjs/showcase/src/showcase/app/welcome/welcome.route.spec.js [new file with mode: 0644]
angularjs/showcase/src/showcase/index.html

diff --git a/angularjs/showcase/src/showcase/app/app.config.js b/angularjs/showcase/src/showcase/app/app.config.js
deleted file mode 100644 (file)
index 3a8490c..0000000
+++ /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);
-      }
-    ]);
-}());
index 2a4e603..b86f10d 100644 (file)
@@ -1,7 +1,8 @@
 describe('app.welcome', function() {
   'use strict';
 
-  var controller, scope;
+  var controller;
+  var scope;
 
   beforeEach(function() {
     module('app.welcome');
index 32786f8..31702c1 100644 (file)
@@ -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 (file)
index 0000000..eaba189
--- /dev/null
@@ -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 (file)
index 0000000..4db3d48
--- /dev/null
@@ -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);
+    });
+
+  });
+
+});
index 2fca851..b3c5607 100644 (file)
     <!-- build:js(.) js/app.min.js -->
     <!-- inject:js -->
     <script src="/src/showcase/app/welcome/welcome.module.js"></script>
+    <script src="/src/showcase/app/welcome/welcome.route.js"></script>
     <script src="/src/showcase/app/welcome/welcome.controller.js"></script>
-    <script src="/src/showcase/app/app.module.js"></script>
-    <script src="/src/showcase/app/app.config.js"></script>
     <script src="/src/showcase/app/core/core.module.js"></script>
+    <script src="/src/showcase/app/app.module.js"></script>
     <!-- endinject -->