javascript - Use of brackets in AngularJS -
my question might stupid having hard time trying determine whether use {} or {{}} or nothing in html angularjs.
i came accross following : 1/ng-src = "{{ mysource }}"
2/ ng-class = "{ active:tab===2 }"
3/ ng-repeat = "foo in foos"
i think understand 3/ instruction not text replacement in 1/ why use simple brackets in 2/?
thanks lot in advance help!
burger
the curly braces in example 2 being used create object literal (see point 2 here) keys map class name , values map class value. it's same braces used when writing things this:
var mydata = { x: 5, y: 6 };
the double braces in example 1 used angularjs templates values inserted html angular.
example 3 uses normal html attributes (exactly <div class="test">
).
Comments
Post a Comment