dimanche 19 avril 2015

How do you check if the data is null in http.get in angularjs AND do something?

My code:



<script>
function customersController($scope, $http) {
$http.get("http://ift.tt/1b8ep6U")
.success(function (response) { $scope.names = response; });
}
</script>

<table class="plansbox" cellspacing="0" rules="all" id="ctl00_ContentPlaceHolder1_FULLTALKTIME" style="border-width:0px;width:100%;border-collapse:collapse;">
<tbody><tr class="rechargeplansheader">
<th scope="col">AMOUNT</th><th scope="col">TALKTIME</th><th scope="col">VALIDITY</th><th scope="col">DESCRIPTION</th>
</tr><tr class="GridRow" ng-repeat="x in names | filter: { plantype: 'TopUp' }" onclick="label1('220');" style="font-family:Verdana;cursor: pointer; cursor: hand;">
<td style="width:10%;">

<span id="ctl00_ContentPlaceHolder1_FULLTALKTIME_ctl02_lblAmount" style="font-weight:bold;">{{ x.Amount }}</span>
</td><td style="width:10%;">
<span id="ctl00_ContentPlaceHolder1_FULLTALKTIME_ctl02_lbltalktime" style="font-weight:bold;">{{x.Talktime }}</span>
</td><td style="width:10%;">
<span id="ctl00_ContentPlaceHolder1_FULLTALKTIME_ctl02_lblvalidity" style="font-weight:bold;">{{ x.Validity }}</span>
</td><td style="width:70%;">
<span id="ctl00_ContentPlaceHolder1_FULLTALKTIME_ctl02_lbldescription">{{ x.Description}}</span>
</td>
</tr>
</tbody></table>


As you can see I am able to get the data, check if the returned data is null, but do to show another div in the null case.


Please help me I am new to angularjs.


Aucun commentaire:

Enregistrer un commentaire