0

I amy trying to populate a ui-sref link with a parameter dynamicall:

ui-sref="business({id:{{business.busId}}})" 

But this does not work.

Any help would be appreciated!

cnak2
  • 1,711
  • 3
  • 28
  • 53
  • Can you post the error you are getting? – acostela Feb 27 '17 at 16:06
  • 1
    Possible duplicate of [How to pass parameters using ui-sref in ui-router to controller](http://stackoverflow.com/questions/25647454/how-to-pass-parameters-using-ui-sref-in-ui-router-to-controller) – acostela Feb 27 '17 at 16:07
  • Error: [$parse:ueoe] Unexpected end of expression: {id: – cnak2 Feb 27 '17 at 16:10
  • I don't think this is a duplicate. The issue is the formatting: Error: [$parse:ueoe] Unexpected end of expression: {id: – cnak2 Feb 27 '17 at 16:12

2 Answers2

1

If you define your state like the following state definition:

.state('business', {
  parent: 'dashboard',
  url: '/business/{businessId}',
  controller: 'BusinessController as vm',
  templateUrl: 'business.html'
})

Then you can call the state like <button ui-sref="business({businessId: business.id})"> Click me </button>

From the a controller you can call the state by calling $state like this: $state.go('business',{businessId: business.id});

You can read more about Using Parameters in Links here

digijap
  • 164
  • 9
0

Have you just tried:

ui-sref="business({id: business.busId})" 
federico scamuzzi
  • 3,708
  • 1
  • 17
  • 24