Hongbo Miao
Hongbo Miao

Reputation: 49724

How to use [src] in non-Angular elements?

I am using A-Frame in Angular 2.

When I put image link directly in src,

<a-scene>
  <a-curvedimage src="https://upload.wikimedia.org/wikipedia/commons/b/be/Random_pyramids.jpg" position="0 2 0"></a-curvedimage>
</a-scene>

it works well. working plunker

However, if I am using

  <a-scene>
    <a-curvedimage [src]="url" position="0 2 0"></a-curvedimage>
  </a-scene>

with

  url = 'https://upload.wikimedia.org/wikipedia/commons/b/be/Random_pyramids.jpg';

It won't give me any error, but it also does not show the image. issue plunker.

How can I solve this issue or any walkaround way? Thanks!

Upvotes: 0

Views: 62

Answers (1)

pkozlowski.opensource
pkozlowski.opensource

Reputation: 117370

I'm not sure what properties the a-curvedimage element has at runtime but it might be the case that it doesn't have the src property that would reflect value of the src attribute. In this case your best option might be binding to the src attribute like so: <a-curvedimage [attr.src]="url" position="0 2 0"></a-curvedimage>

Keep in mind that elements rendered in a browser can have both attributes and properties and Angular distinguishes bindings to those. Most of the time an attribute and the corresponding property names are the same so the difference doesn't matter. Still, there are elements where attributes and property names don't match so you need to be precise in your Angular binding syntax.

Upvotes: 4

Related Questions