我是 angularJS 的初学者,我正在使用 node/bower/grunt 为 angularJS 中的单页应用程序开发 ui,并且我已经安装了 angular-ui-bootstrap 以及来自 angular-ui-utils 的路由和事件实用程序。
I've used ng-class={active:$uiRoute}
on the menu items but when a menu item is selected the active class is not applied...does $uiRoute
handle this or do I need to code it separately?
抱歉问了一个愚蠢的问题......
这是代码:
`<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li ui-route="/" ng-class="{active:$uiRoute}"><a href="#/">Home</a></li>
<li ui-route="/about" ng-class="{active:$uiRoute}"><a href="#/about">About</a></li>
<li ui-route="/other" ng-class="{active:$uiRoute}"><a href="#/other">Other</a></li>
</ul>
</div>
...
<script src="bower_components/angular-ui-utils/modules/route/route.js"></script>
<script src="bower_components/angular-ui-utils/modules/event/event.js"></script>`
和
angular.module('myApp', ['ngRoute','ngResource','ui.bootstrap'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl'
})
.when('/other', {
templateUrl: 'views/other.html',
controller: 'OtherCtrl'
})
.otherwise({
redirectTo: '/'
});
})