美好的一天。我使用了几种方法来使用 ng-show 和 ng-hide 但它们都不起作用。单击按钮时,第一个 div 应该隐藏,第二个出现。请帮帮我!这是我最后尝试的方式:
<div class="parentDiv .col-lg-">
<from class="centerMain">
<div ng-show="showF" class="center-block"> <!-- this div should hides -->
<div>
<label class="center-block">Введите PIN</label>
</div>
<div>
<input name="userName" placeholder="1234" class="center-block inputLine">
</div>
<div>
<button ng-click="showF = !showF" class="center-block buttonBig">Установить PIN</button> <!-- this button makes hiding -->
</div>
</div>
<div ng-show="!showF" class="center-block"> <!--this should appears -->
<div>
<label class="center-block">Подтвердите пин</label>
</div>
<div>
<input name="userName" placeholder="1234" class="center-block inputLine">
</div>
<div>
<button class="center-block buttonBig">Подтвердить</button>
</div>
</div>
</from>
</div>
最佳答案
Angular 2 弃用了许多不必要的 Angular 1 指令。
你可以使用 [hidden]
/[ngIf]
像 [hidden]="showF"
或者 *ngIf="showF”
所有基于事件的指令都已弃用,您可以通过将事件名称包装在 (eventName)
(click)="myFunction()" //instead of ng-click
(focus)="myFunction()" //instead of ng-focus
关于html - 为什么 ng-hide 和 ng-show 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37862527/