Reputation: 675
I have a custom DOM element which is loaded by an external script. I need to pass this element an "event-id" parameter. I tried dynamic property but this isnt supported on the tag:
<widget [event-id]="{{ event.id}}"></widget>
Inspecting widget, no event-id attribute is present because on initial load event
is not set yet. If I manually set the ID it works.
I'm looking for a way to create the DOM element AFTER event
is defined.
Upvotes: 0
Views: 144
Reputation: 1564
You can simply use *ngIf
like this:
<widget *ngIf="event?.id" [event-id]="{{ event.id}}"></widget>
Upvotes: 1