javascript - switch 语句内的 ng-switch 按钮

标签 javascript angularjs

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/

相关文章:

javascript - Angular : Remove a specific template from cache

javascript - JS删除最后一次出现的字符后的所有内容

javascript - 相关 PhoneGap、AngularJs、Ionic、Bootstrap、Jasmine、Grunt、Bower。

java - div 的 Angular ng 变化

angularjs - 如何做http post json数据

javascript - Angularjs URL 在文本区域中的默认值

angularjs - 悬停时的 Kendo Treeview

javascript - JavaScript block 中的服务器控件

javascript - 使用 for 循环处理 ajax 问题

javascript - _.clone 在 lodash 中不起作用?