Marc Rasmussen
Marc Rasmussen

Reputation: 20565

Angular passing misc symbols

I am trying to pass a ★ (★) as a parameter however when I attempt it I get:

syntax Error: Token ''★★' is not a valid identifier'

Here is my code:

<question-rating-stats
        rating-data="{values:[15,15,20,20,30], labels:['&#9733;'.'&#9733;&#9733;','&#9733;&#9733;&#9733;','&#9733;&#9733;&#9733;&#9733;','&#9733;&#9733;&#9733;&#9733;&#9733;'], avg: 3.5}"
        question="{question: 'Give me stars'}">

</question-rating-stats>

So my question is how do I pass these parameters?

Upvotes: 0

Views: 234

Answers (1)

Derlin
Derlin

Reputation: 9881

I think the problem is the "." sign in your label array. If what you want is a concatenation, use +. If there are two items, use ,:

labels:['&#9733;' + '&#9733;&#9733;','&#9733;&#9733;&#9733;','&#9733;&#9733;&#9733;&#9733;','&#9733;&#9733;&#9733;&#9733;&#9733;']

In javascript, . is used to access properties of an object. Here, it tries to access a property of ★★, which is obviously a string, not an object.

Upvotes: 1

Related Questions