Search code examples
angularangularjs-ng-model

What is ngModule in input field in form


I'm new abount Angular and I read a lot of tutorial, Suppose to have this code :

 <input type="text" id="username" class="form-control" [(ngModel)]="username" name="username" required>

I understand that [(ngModel)] can map the input field value with the variable username. Now look this code:

    <form ngNativeValidate (ngSubmit)="onSubmit()" #f="ngForm">
....
     <input type="text" id="username" class="form-control" ngModule name="username" required>
    </form>

What is the difference between ngModule and [(ngModel)] ?


Solution

  • The 2nd part of code you share is wrong. It should be ngModel not ngModule with input .

    @NgModule is an annotation of Angular which allows us to fetch bundle of code related components/services/pipes.