last day (16 days later) » 

6:13 PM
0
A: How do you check if the data is null in http.get in angularjs AND do something?

pankajparkarYou could simply use ng-if="!names", also for more better you maintain a flag which will give you information about data fetching ajax done or not. & that could be very useful while No data found div Controller var customersController($scope, $http) { $scope.dataLoaded = false; //data load...

 
I am using it if($scope.dataLoaded = true) { alert("data loaded");} everytime it is going in to it either data is null or not.
 
@user3630591 did you try what I gave in answer
 
i want to show this div on dataload successful. If the data is null i should show another div
 
@user3630591 look at my update in answer
 
<tr class="no-data-found" ng-if="dataLoaded && !names" colspan="4"> No data found </tr> it is visible although the dataloaded perfectly
 
6:13 PM
if service is returning data as null then do <tr class="no-data-found" ng-if="dataLoaded && names == null" colspan="4"> No data found </tr>
 
the data response will be [ ]
 
that cool
let me update my answer
you could easily achieve by names.length
 
My data response is [] if the data returned is empty . i want to check this and show another div if the data is null
 
check my updated answer
It will surely work
Are you there?
 
yeah i didn't get what you have updated there
kk i got it
 
6:17 PM
yeag
yeah
does it worked?
 
no it is not working its still visible although the data is loaded
 
what is visible?
 
the tr
<tr> No data found
 
that tr should be

<tr class="no-data-found" ng-if="dataLoaded && names.length == 0" colspan="4">
No data found
</tr>
 
yes i have copied that but its still not working is there any other way like .success(function(response) {
$scope.names = response;
});
by doing it here so that i could call jquery function from here
 
6:22 PM
hey there is no need to use jquery
are you using $.ajax?
 
i am sending this var1 and var2 from jquery . its easy to hide or show div in jquery thats why am asking to call jquery if the data is empty
$http.get("https://tic.com/testingservice/HttpService.svc/operator/Var1/Var2")
are u there?
 
yes
it should work
let me create plunkr for you
 
Ok Thank you for your help
 
yes
I'll do it
could you provide me sample data?
please
so that I can give you plunkr in that way
Are you there?
 
{"Amount":10,"Description":"Regular Talktime","Talktime":"7.9","Validity":"0 Days","plantype":"TopUp"},{"Amount":12,"Description":"130 local\/ national sms free.","Talktime":"0","Validity":"30 Days","plantype":"Other"}
 
6:31 PM
ok
 
[{"Amount":10,"Description":"Regular Talktime","Talktime":"7.9","Validity":"0 Days","plantype":"TopUp"},{"Amount":12,"Description":"130 local\/ national sms free.","Talktime":"0","Validity":"30 Days","plantype":"Other"}]
 
I'll do that in 20 mins
 
I going for dinner now
 
where do u stay
Sorry its too late for me i am going to bed now please update the answer its already 12:15 . Good Night . Thank you for your help. Sorry for not staying in chat. Please update the answer please create plunker
 
6:40 PM
India
ok I will do that for sure
 

  last day (16 days later) »