Q:

Angular 4 (click) doesn't fire inside *ngIf

I am new to angular. I am facing problem with (click) in Angular 4. (click) doesn't fire. Tried to search for a solution. Nothing worked out. Following is my code in HTML
<div class="col col-12 col-spacing">
  <div>
  <md-select [placeholder]="result" [(ngModel)]="selectedItemType">
    <md-option *ngFor='let attr of result' [value]="attr.fieldType" ng-selected="attr.fieldType"> {{attr.attribute}}
    </md-option>
  </md-select>
  </div>
  <div *ngIf="selectedItemType =='string' || selectedItemType =='decimal' || selectedItemType == 'text' || selectedItemType == 'integer'">
    <input placeholder="Enter Text" type="text" class="input" [(ngModel)]="txtEntered">
  </div>
  <div>
    <div *ngIf="selectedItemType == 'date'" class="col col-2 col-spacing">
      <md-input-container class="datepicker-align">
        <input mdInput [mdDatepicker]="startDatepicker" placeholder="Select Date" name="StartDate" id="txtStartDate" [(ngModel)]="date"
          #startDate>
        <button id="btnOpnStartDate" mdSuffix [mdDatepickerToggle]="startDatepicker"></button>
      </md-input-container>
      <md-datepicker #startDatepicker></md-datepicker>
    </div>
  </div>
  <div *ngIf="selectedItemType == 'boolean'">
      <input type="checkbox" />
  </div>
  <button *ngIf="selectedItemType" md-raised-button (click)= "Add()" color="accent" >Add</button>
</div>

Here is my backend/typescript code
class TestClass implements OnInit {
    itemSelected: AttrSelectedList;
    chkBox: boolean = false;
    selectedItemType: string = null;
    date: any = null;
    test: any;
    txtEntered: any;
    result: Array<FormatHeader> = [];

    constructor() { }

    handleOnClose() {
      this.dialogRef.close();
    }
    ngOnInit(): void { here we have logic}

    Add() {
      this.test = this.txtEntered;
    }
  }

A:

After formatting the code you will see that the Add method is outside the class Please give proper indentation 
export class TestClass implements OnInit {
  itemSelected: AttrSelectedList;
  chkBox: boolean = false;
  selectedItemType: string = null;
  date: any = null;
  test: any;
  txtEntered: any;
  result: Array<FormatHeader> = [];

  constructor() { }
  handleOnClose() {
    this.dialogRef.close();
  }
  ngOnInit(): void { here we have logic}
}
Add() { // outside class
  this.test = this.txtEntered;
}
} // unnecessary

Add this add method inside the class

