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

ncyBreadcrumb - support for dynamic templateUrl

Open ingikraljevic opened this issue 9 years ago • 5 comments

Hi! I'm currently working on an app that has consist of two submodules (where each module has it's own modules/states) and one of the requirements is that one module should have breadcrumbs displayed in one way, and the other module in another way.

Currently this can't be achieved because the templateUrl can be configured only globally via the $breadcrumb service.

So it would be great if you could set the templateUrl as an attribute and if it's present it would be loaded.

Usage example: A.html:

<div ncy-breadcrumb template-url="path/to/breadcrumbsA.html></div>
<ui-view></div>

B.html:

<div ncy-breadcrumb template-url="path/to/breadcrumbsB.html></div>
<ui-view></div>

This can be achived if the templateUrl of the directive definition object changes from:

templateUrl: $breadcrumb.getTemplateUrl(),

to:

templateUrl: function (el, attrs) {
  return attrs.templateUrl || $breadcrumb.getTemplateUrl();
},

ingikraljevic avatar Mar 30 '16 13:03 ingikraljevic

Hi,

Can we have the url of the state to be overrided if needed to ?

ravikiranr26 avatar Mar 30 '16 23:03 ravikiranr26

Can you give an example or a use case where you would use that? And I think this isn't related to angular-breadcrumbs, but more of a ui-router "thing".

ingikraljevic avatar Mar 31 '16 07:03 ingikraljevic

State 1 )

$stateProvider
        .state('state1', {
            url: '^/{catId}B?name&location',
            ncyBreadcrumb: {
                parent: 'home',
                label: '{{breadCrumb}}'
            },

State 2 )

$stateProvider
        .state('state2', {
            url: '^/{catId}/{dogId}B?name&location',
ncyBreadcrumb: {
                parent: function ($scope) {
                    return $scope.isSingle ? 'home' : 'state1';
                },
                label: '{{breadCrumb}}'
            }

In State 2, as I navigate from home > state 1 > state 2. The Url for state 1 would be 'cat123B?name=a&location=mel' when I'm in state 2, so I don't want the query parameters to be attached and want the state 1 url to be cat123B

ravikiranr26 avatar Mar 31 '16 23:03 ravikiranr26

You should open a seperate issue for that 'cause it doesn't relate to this issue.

ingikraljevic avatar Apr 01 '16 09:04 ingikraljevic

ok sure, thanks. Have already opened.

ravikiranr26 avatar Apr 04 '16 01:04 ravikiranr26