angular.js - Sometimes you need to add {{}} in the ng tag, sometimes you need {}, and sometimes you don't need braces. Are there any rules?
天蓬老师
天蓬老师 2017-05-15 17:02:58
0
1
645

To bind the value in $scope in ng-bind, you need to write {{}}
To bind the value in $scope in ng-src, you need to write {{}}
You don’t need to write {{}}
to determine true or false in ng-checked. In ng-class, you need to write {}

to determine true or false.

When do you need {{}} and when do you need {}? Are there any rules for this?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
迷茫

You remember one thing, as long as it is ng-开关的指令,大都是不需要写的。ng-srcexcept.

ng-src 为什么要呢?主要是因为不能直接用 src ,它会直接请求,不等待 Angular 解析 {{}} ,而 ng-src Mainly to achieve effects similar to this:

<img ng-src="http://www.gravatar.com/avatar/{{hash}}" alt="Description" />

So, that’s it.

ng-class实际上是需要你提供一个对象,所以使用 {} to construct.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template