Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In angular sometimes i have seen curly brackets but some times not.i search a lot but i couldn't find correct question

with curly bracket

ng-src="{{imageSrc}}

without curly bracket

ng-hide="imageSrc"

what i'm asking is why we cannot write ng-hide as

ng-hide="{{imageSrc}} // doesn't work anyway

why there is 2 different syntax for src and hide?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
503 views
Welcome To Ask or Share your Answers For Others

1 Answer

Beacuse they mean two different things. When you use this:

<span data-ng-bind="test">

This means that angular will go to the scope and get value from there with test as key. So value will be $scope.test. But attribte value will be "test"

When you use

ng-src="{{imageSrc}}

then value will be evaluated and placed to the attribute. So value willbe $scope.imageSrc and attribute value will be $scope.imageSrc.

But. Not all tags can wait for evaluation. They think that value {{}} is correct and will not be changed. This cause to bad request. To fix this problem ng-src was created.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...