NativeScript ng2 两种方式绑定在 TextField 上不起作用

2024-02-29

我正在制作一个移动应用程序。在我的登录表单中,我有 2 个文本字段

<TextField hint="Email Address" keyboardType="email" [(ngModel)]="email" autocorrect="false" autocapitalizationType="none"></TextField>
<TextField hint="Password" secure="true" [(ngModel)]="password"></TextField>
 <Label [text]="email"></Label>

在组件.ts中

import { Component, OnInit } from '@angular/core';
import { Router } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { Page } from "ui/page";
import * as Toast from 'nativescript-toast';
@Component({
    moduleId: module.id,
    selector: 'sign-in',
    templateUrl: "template.html"
})
export class SignInPage implements OnInit {
    email: string ="example";
    password: string;
    constructor(private router: Router, page: Page) {
        page.actionBarHidden = true;
    }
    ngOnInit() {

        var loginParams = { user: { email: this.email }, password: this.password };

        console.dump(loginParams);
    }
}

标签显示“示例”,但文本字段不显示。更改文本字段的值不会更改组件逻辑中的值。 任何想法?

附:我已经在我的 @ngModule 中导入了 NativescriptFormsModule


确保不仅在 AppModule 中声明 SignInPage 组件的模块上导入 NativescriptFormsModule。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

NativeScript ng2 两种方式绑定在 TextField 上不起作用 的相关文章

随机推荐