gpt4 book ai didi

angular - NativeScript ng2 双向绑定(bind)在 TextField 上不起作用

转载 作者:搜寻专家 更新时间:2023-10-30 21:15:15 24 4
gpt4 key购买 nike

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

<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>

在 component.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);
}
}

Label 显示“example”但 textField 没有。更改 textField 的值不会更改组件逻辑中的值。任何想法?

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

最佳答案

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

关于angular - NativeScript ng2 双向绑定(bind)在 TextField 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43502810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com