开关支架内的ng-switch按钮

时间:2016-12-06 13:18:25

标签: javascript angularjs

在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: ''
    };
});

1 个答案:

答案 0 :(得分:1)

我只需添加外部div并添加ng-hide

<a href="#" ng-hide="view.name === 'forgotpassword'" ng-click="view.name = 'forgotpassword'">Forgot Your Password</a>