9

Trying to do the following and getting "Got interpolation ({{}}) where expression was expected" error.

<ul>
  <li *ngFor="#item of items">
    <a href='' (click)="foo('{{item.name}}')">{{item.name}}</a>
  </li>
</ul>

Thanks!

1 Answer 1

20

Don't use {{}}(interpolation) inside any event handler code (on a view), do pass expression directly which will get evaluated against Component context(this), like over here you're trying to pass item.name to foo function. So removing {{}} parenthesis would do the trick.

<a href="" (click)="foo(item.name)">
  {{item.name}}
</a>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.