enjoi
enjoi

Reputation: 284

.replace in AngularJs 2

In AngularJS I could do:

<img ng-src="https://someimageurl/{{ foo.replace('bar','') }}" />

How can I achieve the same result in DOM with AngularJS 2?

Upvotes: 1

Views: 796

Answers (2)

sebaferreras
sebaferreras

Reputation: 44659

This

<img ng-src="https://someimageurl/{{ foo.replace('bar','') }} />

is not an angular replace method, is just the javascript replace method being called inside angular interpolation.

In angular2, you can do the same by doing:

<img [src]="'https://someimageurl/' + foo.replace('bar','')"/>

You can find more information about Template Syntax in Angular 2 docs.

Upvotes: 2

Suren Srapyan
Suren Srapyan

Reputation: 68655

Like this:

<img [src]="'https://someimageurl/' + foo.replace('bar','')" />

Upvotes: 1

Related Questions