Angular UI Router: child state is loaded twice when parent and child accept parameter with same name in url

http://plnkr.co/edit/B4RMbBCZKxXcJAWy5B0G

This plunker can reproduce the problem.

I have defined two states in this demo, one parent, one child.

They take a parameter named "someParameter"

in url.

When you transition from parent to child state by clicking the button, you can see in the console, each log statement is executed twice.

Any idea why this is happening? And how do you fix it?

(PS: in my production code, I need a parent and child page to take a parameter with the same name)

+3


source to share


2 answers


You could it

.state('home', {
  url: '/home',
  params: {
    someParameter: ''
  },
  templateUrl: 'partial-home.html',

      



Plunkr example

0


source


I would go with the parameter definition only in the parent state

.state('home.list', {
    url: '/list', //?someParameter',

      



Check the adjusted plunker

And thus, both parent and parent will be supplied with this parameter, and both will be updated if its value changes. Also, double console logging is allowed ...

0


source







All Articles