Issue
I would like to implement img, with a src coming from JSON object.
In AngularJS, I could do:
<img ng-src="{{hash}}" alt="Description" />
Is there any equivalent to this in Angular 2+?
Solution
AngularJS:
<img ng-src="{{movie.imageurl}}">
Angular 2+:
<img [src]="movie.imageurl">
Note that interpolation can achieve the same result:
<img src="{{vehicle.imageUrl}}">
<img [src]="vehicle.imageUrl">
There is no technical difference between these two statements for property binding, as long as you don't desire two-way binding.
Interpolation is a convenient alternative for property binding in many cases. In fact, Angular translates those interpolations into the corresponding property bindings before rendering the view. source
Answered By - Randy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.