Giter Site home page Giter Site logo

Comments (4)

ncuillery avatar ncuillery commented on May 26, 2024

I think you don't use the UI-router well: In your case, the editArticle must be a child of showArticle, then you can benefit of all the features of the UI-router:

.state('showArticle.editArticle', { // the dot defiines a parent/child relation
    ncyBreadcrumb: {
        label: 'Edit article {{ articleName }}',
        parent: // No longer needed
    },
    url: '/edit', // Just the fragment after the parent state's url (no more duplicate) 
    views: {
        '@' : { // target the root view like before if you don't want to rework yours views 
            controller: 'articleEditCtrl',
            templateUrl: 'articleEdit.html'
        }
    }
})

BUT: have a look on #46: it allows url params when specifying ncyBreadcrumb.parent either it is a string or a function.

In your case, something like this should do the job:

.state('editArticle', {
    ncyBreadcrumb: {
        label: 'Edit article {{ articleName }}',
        parent: function ($scope) {
            var param = $scope.slug; // Or wherever is the slug value.
            return 'showArticle({slug: ' + param + '})';
        }
    },
    url: '/article/:slug/edit',
    controller: 'articleEditCtrl',
    templateUrl: 'articleEdit.html'
})

Pending the release, this feature is not yet documented.

I strongly recommend you to use the first solution (UI-router configuration update) :-)

from angular-breadcrumb.

Wykks avatar Wykks commented on May 26, 2024

Oh right, I was aware of parent/child system, but I missed that part :

    views: {
        '@' : { // target the root view like before if you don't want to rework yours views 
            controller: 'articleEditCtrl',
            templateUrl: 'articleEdit.html'
        }
    }

That said, I'll keep in mind the other solution (in case of same parent, from different sources)
Thanks ! 👍

from angular-breadcrumb.

VierenV avatar VierenV commented on May 26, 2024

Hi there,

I am building your first solution @ncuillery but it doesn't keep the scoped variables in the parents.
What I did

   .state('app.enterprises.detailsEnterprise', {
        url: '/:mail',
        views: {
            '@app' : {
                controller: 'enterpriseController',
                templateUrl: 'templates/enterprise.html'
            }
        },
        ncyBreadcrumb: {
          label: '{{client.entreprise}}' //Working great when we are on detailsEnterprise
        },
    })
    .state('app.enterprises.detailsEnterprise.detailsSite', {
        url: '/sites/:id',
        views: {
            '@app' : {
                controller: 'siteController',
                templateUrl: 'templates/site.html'
            }
        },
        ncyBreadcrumb: {
          label: '{{site.lieu.adresse}}' //Working great but we lose client.enterprise
        },
    })

Here I lose the client.enterprise when I move on detailsSite. Is it the expected behavior ?

from angular-breadcrumb.

MrSpark2591 avatar MrSpark2591 commented on May 26, 2024

This works for me.

.state('editArticle', {
    ncyBreadcrumb: {
    label: 'Edit article {{ articleName }}',
    parent: function ($scope) {
         var param = $scope.slug; // Or wherever is the slug value.
         return 'showArticle({slug:" ' + param + '"})'; // here we need to pass " for making it proper string other wise it will not pass param
       }
    },
    url: '/article/:slug/edit',
    controller: 'articleEditCtrl',
    templateUrl: 'articleEdit.html'
})

from angular-breadcrumb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.