1

This sounds very simple but I have been struggling with it!

In AngularJs 1.4, I have an ng-if which is using array's some() function. I get syntax error

Syntax Error: Token '>' not a primary expression at column ...

when doing this.

My HTML is:

<!-- DOES NOT WORK!! -->
<div ng-if="myArr.some(x => x == 'car')">
  Function check fine!
</div>

Here is the plunk https://plnkr.co/edit/v5SLIU5dQdIlpP5sCmzR

Thanks!

1 Answer 1

3

Angular uses its own built-in parser to evaluate the expressions in your templates, which does not support function declarations. You should pull the logic out of your template and into the controller, and then bind to it.

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

2 Comments

Thanks a lot Joe for the quick answer. I have to wait 5 more mins before I can accept it!
@Vikram: Glad I could help :) I think this slips most people up at some point while they're working with Angular 1.x.

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.