angular-breadcrumb icon indicating copy to clipboard operation
angular-breadcrumb copied to clipboard

Dynamic breadcrumb labels are empty on page reload

Open swichers opened this issue 9 years ago • 8 comments

I have a page that lists locations with the ability to click on a location to see details. The breadcrumbs work fine when clicking on an item from the list (Home > Locations > State > City > Location name).

The problem is if you're on a location detail page and reload the page in your browser then the dynamic labels in the breadcrumb are empty (Home > Locations > > >). The details page displays fine otherwise

There is a common on another issue mentioning this same problem. https://github.com/ncuillery/angular-breadcrumb/issues/107#issuecomment-143161637

      .state('app.locations.detail', {
        url: '/:id',
        views: {
          'content@': {
            controller: 'LocationDisplayController',
            templateUrl: '/app/location/html/location-detail.html',
          }
        },
        ncyBreadcrumb: {
          label: '{{location.name}}',
          parent: 'app.locations.city'
        },
      });

Note: the problem is still there even if I simplify the breadcrumbs so that location names immediately follow the default app state.

If I change the label to Testing {{location.name}} then you will see Home > Locations > > > Testing.

swichers avatar Nov 25 '15 22:11 swichers

I got the same issue. I'm not so good at angular just a beginner but I searched component codes slightly. Maybe the reason is behind a few lines of those codes:

var parseLabel = $interpolate(step.ncyBreadcrumb.label);
step.ncyBreadcrumbLabel = step.ncyBreadcrumb.label;

Can any expert examine those lines please?

ismailatkurt avatar Dec 01 '15 20:12 ismailatkurt

If you use $rootScope instead of $scope at controller it will work. But i'm not sure its the right way?

  $rootScope.foo = 'test';

will be work perfect at:

ncyBreadcrumb: {
    label: '{{foo}}',
    parent: 'myparent'
},

ismailatkurt avatar Dec 02 '15 13:12 ismailatkurt

I hacked this by adding a scope variable to the breadcrump called it pageLabel and at the template I evaluate pageLabel || step.ncyBreadcrumbLabel Then I'll pass it from the current page, but it only works for the current page and that's fine with me

maxoizs avatar Jan 25 '16 16:01 maxoizs

Here is an old issue about this problem https://github.com/ncuillery/angular-breadcrumb/issues/42 Solved by injecting $breadcrumb into application .run method.

nbasov avatar Mar 16 '16 12:03 nbasov

@nbasov Thanks, it helped.

xuhcc avatar Apr 11 '16 09:04 xuhcc

2017 and still getting empty labels on page reload. I'd help, but don't know how.

iveretelnyk avatar Feb 23 '17 17:02 iveretelnyk

@iveretelnyk see @nbasov 's comment above. Inject $breadcumb service into the run method of your module.

eyal-magnetic avatar Mar 01 '17 14:03 eyal-magnetic

@eyal-magnetic I tried, in my case it did not help.

iveretelnyk avatar Mar 01 '17 15:03 iveretelnyk