nonplus / angular-ui-router-title

AngularJS module for updating browser title/history based on the current ui-router state.
122 stars 30 forks source link

Access to abstract property for breadcrumbs realization #8

Closed men232 closed 7 years ago

men232 commented 7 years ago

I have some problem with breadcrumbs realization. I need access to "abstract" property of state to avoid clicking on the link:

<li ng-repeat="crumb in $breadcrumbs" ng-switch="$last || !!crumb.abstract">
    <a ng-switch-when="false" href="{{ $state.href(crumb.state, crumb.stateParams) }}">{{ crumb.title }}</a>
    <span ng-switch-when="true">{{ crumb.title }}</span>
</li>
nonplus commented 7 years ago

You can use the $state.get(stateName) method to access the state definition.

I.e. if you put $state on your scope, you can do the following:

<li ng-repeat="crumb in $breadcrumbs" ng-switch="$last || !!$state.get(crumb.state).abstract">
    <a ng-switch-when="false" href="{{ $state.href(crumb.state, crumb.stateParams) }}">{{ crumb.title }}</a>
    <span ng-switch-when="true">{{ crumb.title }}</span>
</li>