NativeScript / nativescript-sdk-examples-ng

NativeScript and Angular code samples.
Apache License 2.0
291 stars 295 forks source link

TextField undefined #229

Closed madsongr closed 6 years ago

madsongr commented 6 years ago

I am following the example but my console.log is returning undefined even after I type some value in TextField. What could be wrong here?

<StackLayout class="p-16">

            <Label text="Name"></Label>
            <TextField class="input input-border" hint="Enter Username" [(ngModel)]="name" editable="true"></TextField>

            <RL:Ripple rippleColor="#df6107">
                <Button text="Signup" (tap)="signup()"></Button>
            </RL:Ripple>

<StackLayout>
import { Component, ViewChild, ElementRef } from "@angular/core";
import { TNSCheckBoxModule } from 'nativescript-checkbox/angular';
import { Color } from "color";

import { MyHttpPostService } from '../../service';

@Component({
    selector: "signup",
    styleUrls: ['./components/signup/signup.css'],
    templateUrl: "./components/signup/signup.html",
    providers: [MyHttpPostService]
})

export class SignupComponent {

    public name: string;

    constructor(private post: MyHttpPostService){

    }

private signup(){
        console.log(this.name);
}
madsongr commented 6 years ago

Solved. I was missing import { NativeScriptFormsModule } from "nativescript-angular/forms"; in app.module.ts. Sorry.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.