html - How to use nested conditions for displaying a hidden block using angular js -


i trying put conditions displaying hidden div. want after entering value in 'name' textbox , if click on search link hidden block should appear. in code, if click on search link first enter value in textbox hidden div appearing. need after entering value in textbox , if click on search hidden div should appear. iam using below code hiding div-

<div ng-show="name.length>0 && isvisible"> 

and in script writing code-

  $scope.isvisible = false;     $scope.showhide = function () {                   //if div hidden visible , vice versa.                $scope.isvisible = true;             }  

i have created plunker here-

https://plnkr.co/edit/ovwzonrn4gtqs1baimbo?p=preview

can 1 me how can achieve this?

you should add condition in method showhide itself:

$scope.showhide = function () {     if($scope.name) {         //if div hidden visible , vice versa.         $scope.isvisible = true;     } }     

if wish hidden section visible when 'search' clicked, make changes per following in html file:

<div ng-show="isvisible"> 

refer demo here


Comments