3

Is it possible to unregister a custom element that has been created by createCustomElement?

We use Web Components to wrap out vertical features, all 'parts' of the feature are downloaded before the Web Component is added to the DOM.

What we would really like is to completely destroy the component when the feature is no longer active but there it looks like there is no API available.

Has anyone had any luck with this?

4

1 回答 1

7

At the Angular level, there doesn't seem to be any "destroy" or "remove" function alongside createCustomElement in @angular/elements.

At the DOM level, looking at the CustomElementRegistry interface, the interface provided by customElements, there is no "undefine" or similar to accompany define. (This may be part of why Angular doesn't have a "destroy" or "remove"...)

So I'd say: No, you can't remove it.

于 2018-12-13T08:15:06.673 回答