Angular directive removes original attribute from element

When adding a directive for some element (for example img

), and if this directive has an attribute from it @Input()

(for example, src

), the original attribute will be changed with ng-reflect-*

(for example ng-reflect-src

), and the image will never be shown because the attribute is src

missing.

This will only happen if it src

needs to be evaluated, doesn't happen on fixed urls!

Is this expected behavior or a bug? Can I get it to work? (At the moment I am fooling him by using src

and source

and having only an entry for directive only source

.)

An example can be seen on the following plnkr (there should be two images, but there is only one): https://plnkr.co/edit/5AjZPeyEfd6IOqxQp3kq?p=preview

+3


source to share


1 answer


I think this is the intended behavior.

A possible workaround could be as follows:



@HostBinding() @Input() src: string;

      

Plunger example

+3


source







All Articles