The following is an HTML code snippets where ngIf checks for forceAngle
to be true, by default forceAngle
is false. Once the button is clicked I call the ForceAngles()
function and set forceAngle
to true. The issue is once it is set to true, ngIf should check the status and show the correct template. At the moment I don't get the changes as expected. I'm new to this domain and surfed for hours on the internet to get a proper solution. I think I missed an Angular fundamental. Need expert support on this.
<ng-container matColumnDef="AssemblyAngle">
<mat-header-cell *matHeaderCellDef [ngClass]='txt-wrapper'> Assembly Angles</mat-header-cell>
<div *ngIf="forceAngle == 'true' ; else inputtemplate;">
<mat-cell *matCellDef="let element">
<span class="txt-inner">{{forceAngle}}</span>
</mat-cell>
</div>
<ng-template #inputtemplate>
<mat-cell *matCellDef="let element" class="txt-wrapper mat-header-cell">
abc
</mat-cell>
</ng-template>
</ng-container>
<button class="btn-secondary" (click)="ForceAngles()">Force Angles</button>
.ts file
ForceAngles() {
this.forceAngle = 'true';
this.loadCompressorOptimizeData();
console.log(this.forceAngle);
return this.forceAngle;
}