I have two components with shared services. So click on button in one component, change the boolean value from another component
shared.service.ts
 sharedService.toggle = false;
comp1.component.HTML
<button class="btn btn-primary" (click)="toggleme()">
comp1.component.ts
toggleme(){
this.sharedService.toggle = !this.sharedService.toggle
}
comp2.component.html
<div class="showHide" *ngIf="this.sharedService.toggle">
............
</div>
    
.togglevalue has changed. See the answer below how to solve