Remove Component from DOM

124 views
Skip to first unread message

Scott L

unread,
Jan 24, 2019, 4:11:57 PM1/24/19
to Angular and AngularJS discussion
What's the best way to remove an Angular component from the DOM? The component wasn't generated dynamically, but rather natively present when the app was launched. Using the directive *ngIf on the component I want to remove does work, however, I didn't know if there was another preferred way of removing the component?

Thanks, in advance.

Sander Elias

unread,
Jan 24, 2019, 10:43:54 PM1/24/19
to Angular and AngularJS discussion

Hi Scott,

Yep *ngIf is it. You can create your own structural directives if you want. For example, you could create an *userHasPermission directive.
Those will really take out the DOM nodes. But you should be less concerned about your DOM nodes. Angular allows you to focus on your data. DOM is just a way to represent it to your user.

Regards
Sander

Scott

unread,
Jan 24, 2019, 11:34:57 PM1/24/19
to ang...@googlegroups.com
Thanks Sander. I will look into that as well.

Best,

Scott

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/oBG5XjIzr18/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages