Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NativeScript ng2 two way binding doesn`t work on TextField

im making a mobile app. In my login form i have 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>

in 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 is showing "example" but textField does not. Change value of textField doesnt change value in component logic. Any Idea?

ps. I already imported NativescriptFormsModule in my @ngModule

like image 279
Kamil Borecki Avatar asked Apr 19 '26 10:04

Kamil Borecki


1 Answers

Make sure you import NativescriptFormsModule on the module that declare SignInPage Component not only in AppModule.

like image 193
GUISSOUMA Issam Avatar answered Apr 21 '26 00:04

GUISSOUMA Issam