Whats equivalent to ng-src in the newer Angular?

AngularJS:

<img ng-src="https://stackoverflow.com/questions/37965667/{{movie.imageurl}}">

Angular 2+:

<img [src]="movie.imageurl">

Angular docs


Note that interpolation can achieve the same result:

<img src="https://stackoverflow.com/questions/37965667/{{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

Leave a Comment

tech