【问题标题】:Nativescript angular 2 component how to?Nativescript angular 2组件如何?
【发布时间】:2016-11-02 13:43:26
【问题描述】:

如何在角度 1 中实现元素指令之类的组件?

这是我的代码,但它不起作用:

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() { }
}

【问题讨论】:

    标签: nativescript angular2-nativescript


    【解决方案1】:
    import {registerElement} from "nativescript-angular/element-registry";
    registerElement("third-party-view", () => require("./third-party-view").SimpleTag);
    

    您可以阅读更多相关信息:https://docs.nativescript.org/angular/plugins/angular-third-party.html

    【讨论】:

    • 通过将组件添加到@NgModule 中的“声明”来使其工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-16
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    相关资源
    最近更新 更多