我正在使用Angular Material导航栏:
<md-content class="md-padding">
<md-nav-bar md-selected-nav-item="selectedItem" nav-bar-aria-label="navigation links">
<md-nav-item md-nav-sref="hid.overview" name="overview">Overview</md-nav-item>
<md-nav-item md-nav-sref="hid.console" name="console">Console</md-nav-item>
</md-nav-bar>
<ui-view></ui-view>
</md-content>
我的js文件
'use strict';
angular.module('rfApp.rffwhid', ['ngRoute', 'ngMaterial', 'ngMessages', 'ui.router'])
.config(['$stateProvider', '$routeProvider', '$urlRouterProvider', function($stateProvider, $routeProvider, $urlRouterProvider) {
$routeProvider.when('/rffwhid', {
templateUrl: 'rffwhid_view/rffwhid.html',
controller: 'View1Ctrl'
});
$stateProvider
.state({
name: "hid",
url: "/hid",
template: "<ui-view></ui-view>"
})
.state({
name: "hid.overview",
url: "/view2",
templateUrl: "view2/view2.html",
controller: 'View2Ctrl'
})
.state({
name: "hid.console",
url: "/rffwhid_console",
templateUrl: "rffwhid_console_view/rffwhid_console.html",
controller: 'rffwhidConsoleCtrl'
});
}])
.controller('View1Ctrl', function($scope, $state) {
var initTab = "overview";
$scope.selectedItem = initTab;
$state.go("hid." + initTab);
});
当我运行它时,我得到:
错误:[$ rootScope:infdig] 10 $ digest()迭代达成。中止!
以递归方式调用$state.go("hid." + initTab);
:(但为什么?我如何设置init标签