ncuillery / angular-breadcrumb

Generate a breadcrumb from ui-router's states
http://ncuillery.github.io/angular-breadcrumb/
MIT License
785 stars 183 forks source link

Issue when parent breadcrumb has a custom label #120

Open cgeo7 opened 8 years ago

cgeo7 commented 8 years ago

I have the route below which basically is has the following setup

forum/create
forum/{forumId}/edit
forum/{forumId}/topics/create
forum/{forumId}/topics/{topicId}
forum/{forumId}/topics/{topicId}/edit

If I leave everything default, with no custom labels everything works as expected. However if in the state main.forum.topics, I use a custom label like in the example, and then I click on the breadcrumb the component tries to navigate to a state with the custom label name. Is there any way to fix this?:

$stateProvider
.state('main.forum', {
        url: "/forum"
        data: {roles: allRoles}
        templateUrl: "components/forum/forum.html"
    })
.state('main.forum.create', {
        url: "/create"
        data: {roles: allRoles}
        views:
            '@main':
                templateUrl: "components/forum/forumCreate.html"
    })
.state('main.forum.edit', {
        url: "/:id/edit"
        data: {roles: allRoles}
        views:
            '@main':
                templateUrl: "components/forum/forumEdit.html"
        params:
            id:
                value: null
                squash: true
    })
.state('main.forum.topics', {
        url: "/:id?searchKeyword"
        data: {roles: allRoles}
        views:
            '@main':
                templateUrl: "components/forum/topics.html"
        ncyBreadcrumb:
            label: "My custom Label"
        params:
            id:
                value: null
                squash: true
            searchKeyword:
                value: null
                squash: true
    })
.state('main.forum.topics.edit', {
        url: ":thematicAreaId/edit/:id"
        data: {
            roles: allRoles
        }
        views:
            '@main':
                templateUrl: "components/forum/topicsEdit.html"
        params:
            id:
                value: null
                squash: true
            thematicAreaId:
                value: null
                squash: true
    })
.state('main.forum.topics.create', {
        url: "/create"
        data: {roles: allRoles}
        views:
            '@main':
                templateUrl: "components/forum/topicsCreate.html"
        params:
            thematicAreaId:
                value: null
                squash: true
    })

The error i get when I click "My custom label breadcrumb is:" Could not resolve 'My custom label breadcrumb' from state 'main' at Object.transitionTo