比方说,我有一个非常大的企业应用程序细分为几个分离的子模块(不要与角度模块混淆)。角度应用程序与他们自己的独立路由器
我不想在一个地方膨胀路由,并希望那些独立的模块(非角度模块)拥有自己的角度和路由模块,否则我必须向这些子模块中的每一个广播路由通知。如果这些子模块可以拥有自己的路由监听器或定义,则为理想选择。
新角度。
模块A
angular.module("navigation", ["ngRoute"]).
config(function($routeProvider, $locationProvider){self.config($routeProvider, $locationProvider)}).
controller("FoliosController", function($scope, $location){self.foliosController($scope, $location)}).
controller("NavigationController", function($scope, $location, $routeParams){self.navigationController($scope, $location, $routeParams)});
angular.bootstrap(document.getElementById("navigation"), ["navigation"]);
//config part
config: function($routeProvider, $locationProvider) {
$routeProvider.
when("/", {templateUrl:"js/modules/search/view/partials/navigation.html"}).
when("/search/folios/:productId", {controller:"NavigationController", templateUrl:"js/modules/search/view/partials/navigation.html"})
},
模块B
var result = angular.module("result", ["ngRoute"]).
config(function($routeProvider, $locationProvider){self.config($routeProvider, $locationProvider)}).
controller("FoliosResultsController", function($scope, $location) {self.foliosResultsController($scope, $location)})
angular.bootstrap(document.getElementById("result"), ["result"]);
//config part
config: function($routeProvider, $locationProvider) {
$routeProvider.
when("/", {templateUrl:"js/modules/search/view/partials/result.html"}).
when("/search/folios/:productId", {controller:"NavigationController", templateUrl:"js/modules/search/view/partials/result.html"})
},
的模块B的路由不工作,所以我不知道,如果我们可以在多个地方路由的听众。
HTML
<div id="navigation" data-ng-cloak>
<ul id="folios" data-ng-controller="FoliosController" class="nav nav-pills nav-stacked">
<li data-ng-repeat="folio in folios" ng-class="{active: isActive('/search/folios/{{folio.productId}}')}">
<a href="#/search/folios/{{folio.productId}}">{{folio.title}}</a>
</li>
</ul>
<ng-view></ng-view>
</div>
编辑: 当我第一次加载文档,两个路由器是针对/搜索/对开执行/:产品ID 但随后在单击列表中的项目,只有moduleA的路由执行。
ui路由器似乎很有希望,多条路线/意见,我也会考虑,以及 – user2727195 2014-09-24 13:14:07