0
votes

I am trying to parse json file and want to display on view. I am able to display data on console but I am not able to display on view .I am using ng-repeat. But, it is not working.

Also, I tried $scope.$apply but it gives error and digest cycle already running but data is not display, why?

Below is my plunker Link:

http://plnkr.co/edit/uyyhxex5gubzTJSZipV0?p=preview

HelloWorldService.doWork().then(function(data){
     console.log("data received to Ctrl");

    $scope.data=data.employees;
     $scope.hide();
    // $scope.$apply();

   })
3
why using ng-controller on body element. dont you need ion-view to display data ?atinder
it not matter why making POCShruti

3 Answers

1
votes

In the service you should convert String to Json by using angular.fromJson(e.data) and it works just fine. See the working example

http://plnkr.co/edit/J3p13z99gRBlHmuSal1c?p=preview

0
votes
$scope.data = JSON.parse(data).employees
0
votes

Your data is a string. You need to parse it with angular.fromJson before you can use it.

HelloWorldService.doWork().then(function(data){
     console.log("data received to Ctrl");

    $scope.data=angular.fromJson(data).employees;
     $scope.hide();
    // $scope.$apply();

   })