I have two divs and want to toggle between them by clicking on button. The following is the code I have tried:
<div id="one" *ngIf="show == true">
Hello One
</div>
<div id="two" *ngIf="show == false">
Hello Two
</div>
<button ng-init="show=true">Click to toggle</button>
I want to toggle between two divs on button click, somehow it is not happening in this case. I am suspecting that show is never set to false. What could be my mistake. I am a rookie in AngularJS. How can I achieve toggle btween two elements on button click? Thanks in advance.
ng-init="show=true", tryng-click="toggle()"and extend the controller with the toggle function, as shown in your answer below.