0

I want to set value into ns-click dynamically, i mean that:

<td ng-click="{{schedule.action}}" ng-init="schedule.action=schedule.action" ng-repeat="schedule in room.Schedule">{{schedule.firstName}}</td>

i'm getting the following error message:

Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{schedule.action}}] starting at [{schedule.action}}].

How to solve this problem?

3
  • You should have function call on ng-click instead of calling variable Commented Dec 1, 2015 at 18:47
  • Possible approach: stackoverflow.com/questions/26151543/… Commented Dec 1, 2015 at 18:48
  • schedule.action in this variable there is different value, but all values are function Commented Dec 1, 2015 at 18:52

1 Answer 1

0

ng-click directive will not interpolation directive {{}} in it, that will throw $parser exception. Basically it can have function call, or code dealing with scope variables.

Markup

<td ng-click="someMethod()" ng-init="schedule.action=schedule.action" 
  ng-repeat="schedule in room.Schedule">
    {{schedule.firstName}}
</td>
Sign up to request clarification or add additional context in comments.

7 Comments

I know what u mean, but i use html table and i want to show different dialog, when user click at the different <td> (table cell). so i need dynamic parameter
@zuri you could use ng-if for showing and hiding div..you need to toggle flag to show hide the relevant div..
when i try that ng-click="reservationModal(schedule.currentDate)" in generated source i'm getting same string. schedule.currentDate value is not passed
@zuri could you give me plunkr..will help you more to solve your issue.
what do you mean in "plunkr" ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.