我在项目中使用 Angular.js 和 $ stateProvider ,我想使用 breacrumbs 我的项目。
注意: .state 中的 网址 没有价值。
我想:在不使用网址的情况下制作 breacrumbs 。
myApp.config(function ($urlRouterProvider, $stateProvider) {
$urlRouterProvider.otherwise('/otherwise');
$stateProvider
.state('page1', {
contoller: 'appController',
url: '',
templateUrl: 'Page1.html',
})
.state('page2', {
contoller: 'appController',
url: '',
templateUrl: 'Page2.html'
})
.state('page3', {
contoller: 'appController',
url: '',
templateUrl: 'Page3.html'
})
.state("otherwise", {
contoller: 'appController',
url: "*path",
templateUrl: "page1.html",
});
});
答案 0 :(得分:0)
您可以通过将状态对象注入控制器来轻松访问它。要获得当前状态:
$state.current
之后你要做的就是将它绑定到模板中的breadcrumb变量。