ngModel value is coming as undefined when used with input

Discussão em 'Angular' iniciado por santhosh, Outubro 23, 2024.

  1. santhosh

    santhosh Guest

    html:

    <input [(ngModel)]="timestamp">
    <button (click)="getInstantDetails()">display</button>


    component.ts

    timestamp: any;
    getInstantDetails(): void {
    console.log(this.timestamp);
    }


    app.module.ts

    import {FormsModule} from '@angular/forms';
    @NgModule({
    declarations: [
    AppComponent
    ],
    imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    ],
    providers: [SchedulerService],
    bootstrap: [AppComponent]
    })
    export class AppModule { }


    I'm getting timestamp value as undefined. is there anything I'm missing here.?

    Continue reading...

Compartilhe esta Página