Reputation: 1250
In angularJS sometimes I'm using curly braces sometimes I can just put it in double quote. Take the following li
tag for example:
<ul ng-repeat="question in questionModel.questionaire">
[...]
<ul ng-repeat="answer in question.answers">
<li><input type="radio"
ng-click="questionModel.handleChange(answer)"
ng-model = "question.answered"
value={{answer}}
name={{$parent.$index}} required>
{{answer}}
</li>
I coded it with trial and error, I never sure if I should be using {{}} or double quotation.
Upvotes: 1
Views: 922
Reputation: 106390
Curly braces handle the interpolation of a value to a string. If you are using a directive that requires a string value, then you should use curly braces.
At all other times, you're omitting the curly braces. This is because value passed to the directive is either a function reference (as in your ngClick
directive), or is an object (as in your ngModel
directive).
Upvotes: 1
Reputation: 4523
Angular has some pre-defined directives that you use in your template like ng-model, ng-show, ng-if and so on. For these you can simply assign values in double quotes
For the ones which are not a part of angular like 'value', placeholder, name etc. if you want to pass data from controller you will have to use curly braces (or whatever symbols you are using for interpolation)
Upvotes: 3