0

I am working on a small AngularJS application. In one of the views, I have replaced some hard-coded html with data coming from a JSON file that I iterate through:

<class="actions-list">
    <div ng-repeat="item in $ctrl.myCustomService.config.items"
         ng-class="{'disabled': !item.isEanabled}"
         class="actions-item"
         ng-click="$ctrl.selectAction('{{item.action}}')">
      {{item.name | translate }}
    </div>
 </div>

The problem is that, since this replacement, the function fired by ng-click, that used to be (hard-coded) ng-click="$ctrl.selectAction('register'); and so on, does not work anymore.

Why does that happen? How can I fix the problem?

1 Answer 1

2

You don't need quotes or {{ }} inside ng-click:

<class="actions-list">
<div ng-repeat="item in $ctrl.myCustomService.config.items"
     ng-class="{'disabled': !item.isEanabled}"
     class="actions-item"
     ng-click="$ctrl.selectAction(item.action)">
  {{item.name | translate }}
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

If you created a reproducable example(jsfiddle for example) it would be easier for someone to understand the problem and help with it

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.