编辑 - 添加了一个plunkr http://plnkr.co/edit/euD4FG?p=preview
没有调用RouteController,请看看
小提琴:http://jsfiddle.net/smartdev101/tv1p9n4h/
angular.module(this.constructor.NAME, ['ngRoute'])
.config(function($routeProvider){
self.config($routeProvider)
})
.controller("RouteController", function($scope, $routeParams){
self.routeController($scope, $routeParams)})
angular.bootstrap(document.getElementById("browser"), [this.constructor.NAME]);
});
HTML
<div id="browser"></div>
<ul>
<li>
<a href="#/attendees/3" target="_self">Racu, Cristian</a>
</li>
<li>
<a href="#/attendees/4" target="_self">Shnider, Brent</a>
</li>
<li>
<a href="#/attendees/6" target="_self">Suess, Mike</a>
</li>
</ul>
答案 0 :(得分:0)
好吧,拼写错误&amp;缺少ng-view。应该是$ routeProverder.when中的控制器,只需将配置更改为:
config: function($routeProvider) {
$routeProvider
.when('/attendees/:param', {
template:"no template",
//constroller: "RouteController"
controller: "RouteController"
})
},
并在您的HTML中添加ng-view。如果没有ng-view
,似乎ngRoute将无法运行<div id="browser">
<div ng-view></div>
</div>