I have an application running with Angular now I am having some issues with the ng-show/hide
and ng-if/switch
, the second case actually works properly, but I ask my self: why I am using ng-if/switch
when everyone uses ng-show/hide
to display/hide content?
here is my code:
$scope.displayStraight = true;
$scope.displayParlayRobin = true;
$scope.displayParlayIfBet = true;
$scope.displayParlayTeaser = true;
$scope.showBetType = function(betType) {
$ionicScrollDelegate.resize();
$ionicScrollDelegate.scrollTop();
$scope.displayStraight = false;
$scope.displayParlayRobin = false;
$scope.displayParlayIfBet = false;
$scope.displayParlayTeaser = false;
$timeout(function() {
$scope[betType] = true;
}, 150);
and here is some of the content in my HTML:
ng-hide:
<div ng-hide="betSlip.length">
<div>
No picks yet
</div>
ng-if:
<div ng-if="displayStraight">
<div>
Straight Bet
</div>
2-
<ion-list ng-if="displayStraight">
I had this last one this way and wasn’t working as expected:
<div ng-show="betSlip.length >= 1">
now I change it to:
<div ng-if="betSlip.length >= 1">
and it works properly, so, what am I doing wrong with the ng-show/hide
? is there any issues with the performance by using ng-if/switch
? what do you recommend ?