I can't get json data with ng-repeat in my ionic app

Issue

I’m a newbie so please explain step by step as you can.

I face a little problem in my ionic app, I can’t get json data from the link.

I can see json data in log console but in ng-repeat didn’t import any data!

i.e: json file is too long but here is example:

https://quarkbackend.com/getfile/arbmarket/jsfile

in app.js:

(function(){
var app = angular.module('nJson', ['ionic']);

app.controller('nCtrl', function($http, $scope){
$scope.health = [];

$http.get('https://quarkbackend.com/getfile/arbmarket/jsfile')
    .success(function(response){
        $scope.linux = data.linux;
        $scope.andro = data.android;
        $scope.applica = data.application;
        $scope.social = data.socials;

        //console.log(response);
    });

});


app.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {

      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }

    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
    });
 });
}());

in android.html:

<body ng-app="nJson" ng-controller="nCtrl">
.....
<ion-content>
        <br />
        <div class="list card">

          <div class="item item-body">
     <a onClick="'{{n.nlink}}', '_blank', 'location=yes', 'toolbar=yes'" ng-repeat="n in andro">
      <h3>{{n.ntitle}}</h3>
      <img class="full-image" src="{{n.nimg}}">
      </a>
        <hr>
  </div>
</div>
</ion-content>

My steps:

ionic start myapp blank

ionic platform add android

ionic plugin add cordova-plugin-inappbrowser

ionic build android

ionic serve

Did I miss something?

i manually add posts without ng-repeat and json file to get my point.
here is screenshot:

ScreenShot

Solution

You are using response parameter not data, data is undefined.

    $http.get('https://quarkbackend.com/getfile/arbmarket/jsfile')
        .success(response => {
            $scope.linux = response.linux;
            $scope.andro = response.android;
            $scope.applica = response.application;
            $scope.social = response.socials;
        });
    });

Answered By – Marko Savic

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published