javascript - the variable which is define inside ng-init not reflecting changes through out the view in angular js -


i have following code:

<div ng-init="showlogin=true;">     <div ng-if="showlogin">        <span> show login value is:{{showlogin}} </span>////here value true after click on create accoun          <form class="login-form">          ............          ............          <div class="create-account">             <p>                  don't have account yet ?&nbsp; <a href=""  ng-click="showlogin=false;">                  {{showlogin}}                 create account </a>             </p>         </div>         </form>     </div>      <div ng-if="showlogin">         <span> show login value is:{{showlogin}} </span>//here value true after click on create accoun          <form class="registration-form">          ............          ............          <div class="create-account">             <p>                 <a href=""  ng-click="showlogin=true;">login </a>             </p>         </div>         </form>     </div> </div> 

initially shows both login , registration page. fine according code. when click on create account both form should hide still no form hide.the value of showlogin above login form false , above registration form true.i don't know doing wrong step. if have idea solve issue please suggest me?

don't use ng-init if can it, variable may local.

instead initialize value in controller:

$scope.showlogin = true; 

and when want flip state, use functions:

<a href=""  ng-click="showlogin=true;">login </a> // change <a href=""  ng-click="changeshowlogin(true)">login </a> //  $scope.changeshowlogin = function(value){    $scope.showlogin = value; } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

django - CSRF verification failed. Request aborted. CSRF cookie not set -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -