I am doing a dashboard with live update, so after $http call when a db returns null object i want to assign default value as zero
$scope.SAP=0;
$http({
method: 'GET',
url: 'getTilesDataForPrjectReport.do',
}).then(function(response){
if(response.data.proj==='SAP'){
$scope.SAP=response.data;
}
}
});
<div style="height:20%; background-color:#ff9e97;">
<p id="colorPalletDashboardTileRed"> {{SAP.red}}</p>
<p id="colorPalletDashboardTileAmber">{{SAP.amber}}</p>
<p id="colorPalletDashboardTileGreen">{{SAP.green}}</p>
</div>
<div style="height:18%; background-color:#ff8a81;">
<p> Total Projects : {{SAP.totalProj}} </p>
</div>
If SAP is not in response data, i need to display 0 in all SAP bindings,
even if i assign 0 to $scope.SAP, it's not reflecting in html. I know it could be done with ng-hide with another <p> tag, but what's the simplest solution