Sheph
Sheph

Reputation: 675

Angular, create DOM element after data is ready?

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

Answers (1)

Asaf
Asaf

Reputation: 1564

You can simply use *ngIf like this:

<widget *ngIf="event?.id" [event-id]="{{ event.id}}"></widget>

Upvotes: 1

Related Questions