2016-12-06 57 views
0

開關按鈕,但它只有當它的外面switch語句這裏是我的代碼工作:NG-開關按鈕steatment 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: '' 
    }; 
}); 
+0

你的代碼正在工作......當點擊'Forgot password'時,它顯示forgotpassword div – Weedoze

回答

1

我只是添加外格,並添加ng-hide

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