Add text parameters in angular ui-sref

120 views Asked by At

I am trying to add parameters to ui-sref. If I try this it works perfectly

<a ui-sref="services.test({ id: 2 , other_id: 3 })">test</a>

But If I try this it don't work

<a ui-sref="services.test({ id: firstexmple , other_id: secondone })">test</a>
1

There are 1 answers

0
Tomek Sułkowski On BEST ANSWER

If you try to set the id to literal value "firstexample" and other_id to "secondone" you need to write them as you would write strings in plain JavaScript code, so:

<a ui-sref="services.test({ id: 'firstexmple' , other_id: 'secondone' })">test</a>

(mind that you can't use double quotes (like this id: "firstexmple") because you're already using them as to wrap the whole ui-sref attribute's value.