Reputation: 2756
When I do
<div>my image : {{myVar}}</div>
my browser displays
<div>my image : [object HTMLImageElement]</div>
How can I display the image itself instead?
Upvotes: 4
Views: 4748
Reputation: 11
Replace src by attr.src. Try this
my image : img attr.src={{image.source}}>Upvotes: 0
Reputation: 321
Any specific reason why you can't do something like
<div>my image : <img src={{image.source}}></div>
instead?
Upvotes: 2
Reputation: 657821
I don't think there is a way to add an HTMLImageElement
though Angular bindings.
This should work:
<div>my image : <span #imgTarget></span></div>
@ViewChild('imgTarget') imgTarget:ElementRef;
ngAfterViewInit() {
this.imgTarget.nativeElement.appendChild(this.myVar);
}
Upvotes: 4