Disable the button when fields are empty in Angular5 [ invalid form ]

Ela*_*n M 2 angular-validation angular

I am learning Angular5, new to this.

I have two input fields, one button. Handled validations for that two fields, will enable the button once two fields are entered. I have disable the button when the form is invalid. But it is not working.

<form class="customerRegisteration-form">  
  <div class="form-row">
  <div class="form-group col-md-6">
    <label for="firstName">First Name</label>
      <input required ngModel name="firstName" id="firstName" class="form-control"  placeholder="First Name" #firstName="ngModel"/>
      <div class="alert alert-danger" *ngIf="firstName.touched && !firstName.valid">First Name is required</div>
  </div>
  <div class="form-group col-md-6">
    <label for="lastName">Last Name</label>
    <input required ngModel name="lastName" id="lastName" class="form-control" placeholder="Last Name" #lastName="ngModel"/>
    <div class="alert alert-danger" *ngIf="lastName.touched && !lastName.valid">Last Name is required</div>    
  </div>
  </div>
  <div class="form-group col-md-4">
      <button type="submit" class="btn btn-lg btn-block btn-info" [disabled]="!customerRegisteration.valid">
        <i class="fa fa-floppy-o"></i> Submit</button>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

Kindly help me if anything wrong.

Thanks in Advance.

Saj*_*ran 5

Your Form should have a formGroup as

<form  [formGroup]="customerRegisteration">
Run Code Online (Sandbox Code Playgroud)

or

 <form class="customerRegisteration-form" #customerRegisteration="ngForm">
Run Code Online (Sandbox Code Playgroud)

and then,

<button type="submit" class="btn btn-lg btn-block btn-info" [disabled]="!customerRegisteration.valid">
Run Code Online (Sandbox Code Playgroud)