0

I am working on SPA using AngularJS, the app divided into modules, and each modules has its own route configuration, my question here what is the order that angular use to build its route table? will it mix all routes from different modules into one route table? What if there is a path (when("/")) founded twice (check code below)?

In this snippets, I have "/" path which is found in main and home modules:

(function () {
"use strict";

// create main module and inject it with home module:

angular.module("main", [
    "home"
]);

 //route configuration for main module:

angular.module("main").config([
    "$routeProvider", function($routeProvider) {
        $routeProvider
            .when("/",
            {
                templateUrl: "/app/views/Main.html",
                controller:  "MainController"
            }).when("/dioe",
            {
                templateUrl: "/app/stepTwo_dioe/goe/views/goe.html",
                controller:  "GOEController"
            }).otherwise({ redirectTo: "/" }); 
    }
  ]);
})();

and the home module is pretty the same:

(function () {

"use strict";

angular.module("home", []);

 //route configuration for main module:

angular.module("home").config([
    "$routeProvider",  function($routeProvider) {
        $routeProvider
            .when("/",
            {
                templateUrl:"/app/home/views/home.html",
                controller: "HomeController"
            }).otherwise({ redirectTo: "/list" }); 
    }
  ]);
})();
4

0 回答 0