I have gone through so many questions like this but got this only solutions that ng-show
by default hides the element and show it if condition is true and on the other hand ng-hide
by default show the element and hide it when condition is true.
But my concern is the condition can be taken care of with ng-show
or ng-hide
only then why we use different things.
For example
I saw this somewhere in this code user is using ng-show
and ng-hide
both
<div ng-init="isShow = 'one'">
<a href="#" ng-click="isShow == 'one' ? isShow = 'two' : isShow = 'one'">
<div ng-show="isShow=='one'">
If One show this
</div>
<div ng-hide="isShow=='one'">
If Two show this
</div>
</div>
But according to me this can be achieved also with this code
<div ng-init="isShow = 'one'">
<a href="#" ng-click="isShow == 'one' ? isShow = 'two' : isShow = 'one'">
<div ng-show="isShow=='one'">
If One show this
</div>
<div ng-show="isShow=='two'">
If Two show this
</div>
</div>
So what exactly is the difference between both the codes. There must be some specific difference if ng-show
and ng-hide
both exists. Anyone know it?
Thanks in advance!