angularjs - Can I use ng-click with ng-if to hide and show two different sections simultaneously -


i'm working on app in angularjs , trying directly in dom. while know not greatest practice, pretty practical in case since i'm trying circumvent controller. tried hook button ng-click 2 functions true , false, using ng-if show , hide section. 2 functions because there 2 sections. i'd if 1 button clicked 1 section shows while other hides , vice versa. sort of works, never hide first section. also, in attempts, got sort of working not default 1 element on load. ideas? code looks like:

<button class="add col-xs-6 col-sm-6 col-md-3 col-lg-3 add-btn" ng-model="showthis=true" ng-click="showme=false; showthis=true">add</button> <button class="edit col-xs-6 col-sm-6 col-md-3 col-lg-3 edit-btn" ng-click="showme=true; showthis=false">edit</button>  <div ng-if="showthis">     {a section of code} </div>  <div ng-if="showme">     {another section of code} </div> 

i set single variable, , use toggle between 2 divs:

<button class="add col-xs-6 col-sm-6 col-md-3 col-lg-3 add-btn" ng-model="showme=true" ng-click="showme=false">add</button> <button class="edit col-xs-6 col-sm-6 col-md-3 col-lg-3 edit-btn" ng-click="showme=true">edit</button>  <div ng-if="showme">     {a section of code} </div>  <div ng-if="!showme">     {another section of code} </div> 

if showme true, top block display, , ! or not operator hide second block (!true == false).


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -