Angular Js - ui-router中的Breadcrumbs

时间:2015-10-15 10:03:59

标签: angularjs angular-ui-router breadcrumbs

我在项目中使用 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",
    });
});

我是这样的: enter image description here

1 个答案:

答案 0 :(得分:0)

您可以通过将状态对象注入控制器来轻松访问它。要获得当前状态:

$state.current

之后你要做的就是将它绑定到模板中的breadcrumb变量。