Anjularjs ng-src:
Anjularjs provides ng-src
directive for get the path of image file from expression
<img src="/IMAGES/APMAP.png" alt=”andharapredesh” style="height:200px;" width="200px" />
In case of dynamically binding image path to img in anjular we have to use binding expression.
<img src="{{State.flagpath}}" alt={{State.CityName}} style="height:200px;" width="200px" />
Here issue is expression will be validated once
controller and state object is initialized.
So initially it will consider {{State.flagpath}} as path---gives error. Once
state object initialized. It will get object path display image.
2 requests one is validated before state object
constructed another one after state object is constructed.
so best practice is use ng-src={{ State.flagpath}}} which is evaluated once
state object is initialized.—expression will be evaluated.
No comments:
Post a Comment