1

This is my code :

ng-click="create({{item.variants[0].id}},{{item.variants[0].title}})"

and the errors :

Error: [$parse:syntax] Syntax Error: Token 'Title' is unexpected, expecting [)] at column 26 of the expression [create(743922959,Default Title)] starting at [Title)].

what should i suppose to do in order to make clean function without errors but still preserve parameter that i put into it.

1 Answer 1

2

You should just remove interpolation there. Just do:-

  ng-click="create(item.variants[0].id, item.variants[0].title)"

or just pass in variants and access id, and title from the object passed to your handler:-

 ng-click="create(item.variants[0])"

Because when doing the way you did it will create the expression as create(743922959,Default Title) which is invalid in javascript. Because the second argument which is supposed to be a string Default Title is passed in as token.

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

Comments

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.