Get the value from the mat-input in angular material

Discussão em 'Angular' iniciado por Hari Haran, Dezembro 21, 2024.

  1. Hari Haran

    Hari Haran Guest

    As im new to the angular. I just want to get the value from the mat-input I need to get the value from the angular mat-input. Can someone help me to do this. Thanks in advance

    <div fxLayoutAlign= "center center" fxFlexFill class="main-div">
    <mat-card fxFlex= "20">
    <mat-toolbar color="primary" c>Bonbloc Login</mat-toolbar>
    <form fxLayoutAlign="stretch" fxLayout = "column" class="login-form">
    <mat-form-field>
    <input matInput required [(ngModel)] = "email" placeholder="email Id">
    <mat-hint align="end">Min 5 characters</mat-hint>
    </mat-form-field>

    <mat-form-field>
    <input matInput required [(ngModel)] = "password" type="password" placeholder="password">
    </mat-form-field>
    <button mat-raised-button type="submit" (click) = "login()">Login</button>
    <h1>Hi {{email}} {{password}}</h1>
    </form>
    </mat-card>


    login() {
    console.log(this.email, this.password)
    };

    Continue reading...

Compartilhe esta Página