1

How do i implement a component like a element directive in angular 1?

This is my code but it doesn't work:

import {Component} from "@angular/core";

@Component({
    moduleId: "TestComponent",
    selector: "TestComponent",
    template: '<Label text="TEST COMPONENT" textWrap="true"></Label>'
})
export class TestComponentComponent {
    constructor() { }
}

@Component({
    selector: "my-app",
    template: `
    <StackLayout>
        <Label text="TEST"></Label>

        <TestComponent></TestComponent>
    </StackLayout>
    `
})
export class AppComponent {
    constructor() { }
}

1 Answer 1

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

You can read more about it: https://docs.nativescript.org/angular/plugins/angular-third-party.html

Sign up to request clarification or add additional context in comments.

1 Comment

Got it to work by adding the component to "declarations" in the @NgModule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.