monstro monstro - 6 months ago 49
AngularJS Question

angular ng-click ng-show stopped working

I have this small code fragment:

<li ng-if="" ng-click="expand=!expand">{{}}</li>
<li ng-if="" ng-show="expand">{{}}</li> and contain values.

LongDescription is hidden, but when I click on Description, it becomes visible.
I toggle like this by setting expand flag true or false.

Why this code is not working ??


ng-if uses isolated scope that is why you cannot link your primitive variable (expand), so if you can just change expand to vm.expand and it will work...

and your ng-show is not needed there you already have ng-if for it...

<li ng-if="" ng-click="vm.expand=!vm.expand">{{}}</li>
<li ng-if=" && vm.expand">{{}}</li>

and here is working PLUNKER