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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -