cnak2
cnak2

Reputation: 1841

Trying to pass a ui-sref param dynamically

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!

Upvotes: 0

Views: 199

Answers (2)

digijap
digijap

Reputation: 164

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

Upvotes: 1

federico scamuzzi
federico scamuzzi

Reputation: 3778

Have you just tried:

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

Upvotes: 0

Related Questions