Importing components in Nativescript Angular


I recently start playing with Nativescript (angular) and I wanted to import a video player plugin. Everything worked great however I was a little confused with the code they used in demo which lead me to this page: Integrating UI components with Angular

Following the example provided

import {registerElement} from "nativescript-angular/element-registry";
registerElement("third-party-view", () => require("./third-party-view").SimpleTag);

and then use third-party-view in your template <third-party-view prop1="value1"></third-party-view> got me thinking why do you need to use registerElement instead of importing the component from an Angular module? After all that is the Angular way of doing things, or am I missing something?


Not all the plugins are Angular compatible. If the author of a plugin supports Angular, he would have written the appropriate Angular module which you will just import. Register element is an alternative when the plugin doesn’t impelement Angular module out of box.

Answered By – Manoj

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.