Problem Question -
I am trying to use ng-show and ng-hide but I don't know where I am making mistake.When my object is empty it is not hiding the div.
Can someone please guide me on this is much appreciated
//this is my view
<div class="main" ng-controller="myCtrl">
<div ng-show="show">
Show me as json object is not empty
</div>
<div ng-hide="show">
hide me as my json object is empty
</div>
</div>
//my controller
myCtrl();
function myCtrl() {
Service.getMoney()
.success(function (data) {
if(data !=null || data != 'undefined'){
$scope.data = data;
$scope.show= true;
console.log(cart);
}
else{
$scope.show= false;
}
})
.error(function (status, data) {
console.log(status);
})
};
Please guide me where I am making mistake. Also my json(data) is coming like this (Object {}) if it is empty
Update answer: It was nothing to do with ng-show and ng-hide. I have to just check my json object
if (data.value)
// Thanks to @shomz