首页 文章

带有Page标签的Angular 2自定义html的NativeScript

提问于
浏览
0

我正在尝试使用Angular 2在NativeScript中创建一个自定义页面 . 我在某处读到我所要做的就是将它添加到一个html文件中 .

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded" actionBarHidden="true">
<ActionBar title="Create">
    <NavigationButton text="Back" android.systemIcon="ic_menu_back"></NavigationButton>
    <ActionItem text="Save" (tap)="save()" ios.position="right"></ActionItem>
</ActionBar>
<StackLayout>
    <TextField hint="First Name" [(ngModel)]="firstname"></TextField>
    <TextField hint="Last Name" [(ngModel)]="lastname"></TextField>
</StackLayout>
</Page>

但这给了我一个错误 . 我还尝试将其添加到xml文件并更新组件模板标记,以便它指向它 .

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

@Component({
    selector: "app",
    templateUrl: "pages/login/login.xml"
})

这也给出了错误 . 所以我很困惑 . 如何将 Page xml添加到html文件?

编辑:我应该补充说,我添加 <Page> 的原因是我可以隐藏actionBar . 我读到我能做到这一点的唯一方法是将 actionBarHidden="true" 添加到 <Page> 元素

2 回答

  • 0

    我找到了我的主要目标的答案 . 隐藏ActionBar可以通过依赖注入来完成 .

    import {Page} from "ui/page";
    
    @Component({
    // ...
    })
    class MyComponent {
      constructor(page: Page) {
        page.actionBarHidden = true;
      }
    }
    

    https://github.com/NativeScript/nativescript-angular/issues/97

  • 3

    (我会评论,如果我可以:X)

    这里有好消息!我昨天很难知道如何做到这一点 . 哈哈谢谢你!

相关问题