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

Query Params get carried over to the parent state

Open namkn opened this issue 10 years ago • 5 comments

Hi, is there a reason why you need to pass the url params from the current state to the destination (the parent breadcrumb link). Most of the time the url params of this state is not applicable/related to the parent state at all. In my case it'd fail saying the sorting fields (in the current state) are not found in the parent ('s table)

Related code: conf.ncyBreadcrumbLink = $state.href(ref.state, parentParams || $stateParams || {});

Example: my breadcrumbs are like this: Home > Jobs > Single Job > Job Applications in Job Applications' url I have sort=submitted_on. When I click on the Jobs breadcrumb link, the url param: sort=submitted gets attached to the end of the Jobs' url which causes a failure.

Thanks for looking.

namkn avatar Mar 24 '15 14:03 namkn

I can't reproduce the bug, I made a Plunker with queryparams. Here is my procedure:

  • Run the plunker in a separate window (blue button in the right top corner) to see the url in the address bar
  • Click on "Element 1", then "Detail"
  • The url is http://run.plnkr.co/Ftqujt7NY7O40wrx/#/element1/detail?myParam=myValue
  • Navigate back to "Element 1" in the breadcrumb
  • The url is "http://run.plnkr.co/Ftqujt7NY7O40wrx/#/element1", the query param is no longer attached.

Please can you update the plunker above in order to reproduce the bug. Posting your router configuration here could be useful too.

ncuillery avatar May 16 '15 13:05 ncuillery

(and sorry to let the issue unanswered during a long time)

ncuillery avatar May 16 '15 13:05 ncuillery

I'm not sure how to save the plunker. But basically I added "?param" to the "element" state's url in script.js and also added ({param: 'asd'}) to the ui-sref link in element.html. Now when you go back to "Element 1" from the Detail page, you'll see "?param=asd" attached to the end of the element page's url

The temporary fix I did for my app was to remove "|| $stateParams" in the code pasted in the first comment above.

Thanks for looking

namkn avatar May 18 '15 16:05 namkn

Hi,

How to pass params to State when we click on intermediate parent links in breadcrumb..?

tanaji-bhale avatar Feb 01 '16 18:02 tanaji-bhale

I can go to that state by using this - $state.go('root.state1', {objId: obj.objId,objText: obj.text}); , But not able to go that state when we click on intermediate parent links in breadcrumb, due to state level config does not allow us to pass state param...

I configured state label like this -

$stateProvider.state('root.state1', { url: "/state1", templateUrl: "/root/state1.html", controller: 'State1Ctrl', params: { objType: null, objId: null }, ncyBreadcrumb: { label: '{{state1Name}}', //updated in controller scope parent: 'root' }

tanaji-bhale avatar Feb 01 '16 18:02 tanaji-bhale