user308553 user308553 - 8 months ago 21
AngularJS Question

angularJS when to use curly braces when to use quotation

In angularJS sometimes I'm using curly braces sometimes I can just put it in double quote. Take the following

tag for example:

<ul ng-repeat="question in questionModel.questionaire">
<ul ng-repeat="answer in question.answers">
<li><input type="radio"
ng-model = "question.answered"
name={{$parent.$index}} required>

I coded it with trial and error, I never sure if I should be using {{}} or double quotation.


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).