I want to pass in a parameter to ui-sref using UI-Router. Usually it would be something like:
ui-sref="example.state({param: value})"
However, in my controller I set the routes in an array of objects like:
self.dynamicId = $stateParams.id;
self.menu = [
{
label: 'Example1',
route: 'example.state1',
stateName: 'state1'
},
{
label: 'Example2',
route: 'example.state2',
stateName: 'state2'
}
];
How do I pass in the dynamicId parameter using an Angular expression in my template?
<div ng-repeat="link in menu">
<a ui-sref="{{ link.route }}"></a>
</div>
Right now I'm hardcoding the state name, which sort of defeats the purpose of using ui-sref:
<a ui-sref="example.{{stateName}}({id: dynamicId})"></a>