0

i have a init function for rate functionality

This is working fine

<div data-ng-init="rating = 5">

But rating values are dynamic ,

<div data-ng-init="rating = {{ datasourcelist.rating }}">

But this is throwing error

(Error: Syntax Error: Token 'datasourcelist.rating' is unexpected, expecting [:] at column 13 of the expression [rating = {{ datasourcelist.rating }}] starting at [datasourcelist.rating }}].)

Please help ,

1
  • Just do rating = datasourcelist.rating Commented Sep 11, 2013 at 13:09

2 Answers 2

3

When you use angular directives you do not need to put double brackets so

<div data-ng-init="rating = datasourcelist.rating">

should work.

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

Comments

1

{{ .. }} is called interpolation, which will transform the model value to a string. It returns a string.

data-ng-init="rating = {{ datasourcelist.rating }}" is just like assigning a string to the model object rating.

What you need is object assignment:

data-ng-init="rating = datasourcelist.rating"

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.