Reputation: 24562
How can I pass a calculated string to a function in AngularJS ?
Here's the code that I have:
<div ng-click="wos.wordFormRowClicked(wf)"
ng-form="wos.wordFormNgForm_{{wf.wordFormIdentity}}"
ng-repeat="wf in wos.word.wordForms">
<div>
<div ng-click="wos.wordFormDefinitionRowClicked(d)"
ng-repeat="d in wf.wordDefinitions">
<div>
<span ng-click="wos.wordFormDeleteDefinition("wos.wordFormNgForm_{{wf.wordFormIdentity}}", wf.wordFormId, d.wordDefinitionId)"
></span>
</div>
I'm trying to pass a string as the 1st parameter of the function wos.wordFormDeleteDefinition
but it is giving me a run time error. How can I do this?
Upvotes: 2
Views: 58
Reputation: 16650
Since you want the string to be interpolated, pass the expression and the string as 2 differnt values to function and handle them in your controller:
<span ng-click="wos.wordFormDeleteDefinition('wos.wordFormNgForm_', wf.wordFormIdentity, wf.wordFormId, d.wordDefinitionId)"
></span>
Upvotes: 1
Reputation: 4401
You could try this - initialize a new model str_param
using ng-init
<span ng-init="str_param = (wos.wordFormNgForm_{{wf.wordFormIdentity}} | toString)"
ng-click="wos.wordFormDeleteDefinition(str_param, wf.wordFormId, d.wordDefinitionId)">
</span>
PS: I am not sure what these values are, if the above code fails, try removing the {{}}
and | toString
to see if that works.
Upvotes: 1