switch 按钮位于 switch 语句内,但仅在 switch 语句外部时才有效这是我的代码:
<div ng-controller="LoginController as LC">
<div ng-switch on="view.name">
<div ng-switch-default>
<input type="email" required>
<input type="password" required>
<button type="submit" class="form-submit">Login</button>
<a href="#" ng-click="view.name='forgotpassword'">Forgot Your Password</a>
</div>
<div ng-switch-when="forgotpassword">
<input type="email" equired>
<button type="submit" class="form-submit">Send</button>
</div>
</div>
</div>
.controller('LoginController', function ($scope, ModalService) {
$scope.view = {
name: ''
};
});
最佳答案
我只是添加外部 div 并添加 ng-hide
<a href="#" ng-hide="view.name === 'forgotpassword'" ng-click="view.name = 'forgotpassword'">Forgot Your Password</a>
关于javascript - switch 语句内的 ng-switch 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40996370/