Alan Alan - 2 years ago 111
AngularJS Question

How can I pass a string in the click event with AngularJS?

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-repeat="wf in wos.word.wordForms">
<div ng-click="wos.wordFormDefinitionRowClicked(d)"
ng-repeat="d in wf.wordDefinitions">
<span ng-click="wos.wordFormDeleteDefinition("wos.wordFormNgForm_{{wf.wordFormIdentity}}", wf.wordFormId, d.wordDefinitionId)"

I'm trying to pass a string as the 1st parameter of the function
but it is giving me a run time error. How can I do this?

Answer Source

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)"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download