1

即时制作移动应用程序。在我的登录表单我有2周的TextFieldNativeScript ng2双向绑定不适用于TextField

<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); 
 
    } 
 
}

标签显示 “榜样”,但文本框不。更改textField的值不会更改组件逻辑中的值。 任何想法?

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

回答

4

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

+0

我在我的组件中导入了这个模块仍然没有工作:( –

+0

为你的模块添加代码 –

+0

我不知道你在第一时间我做了Yoy说的和它的工作谢谢队友! –