Show array data from json file into ionic app using angularjs http


#1

here is the html

<link rel="manifest" href="manifest.json">

<!-- un-comment this code to enable service worker
<script>
  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('service-worker.js')
      .then(() => console.log('service worker installed'))
      .catch(err => console.log('Error', err));
  }
</script>-->

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<ion-pane>
  <ion-header-bar class="bar-stable">
    <h1 class="title">AlSharq New App</h1>
  </ion-header-bar>
  <ion-content>
  <div ng-repeat ="story in stories">
  {{story.title}}
  </div>
  </ion-content>
</ion-pane>

here is app.js

(function() {

var app = angular.module(‘alsharq’, [‘ionic’]);

app.controller(‘alsharqctrl’, function($http, $scope) {

$scope.stories = [];

$http.get(‘https://rss2json.com/#rss_url=http%3A%2F%2Fwww.alsharq.net.sa%2Ffeed’)

.success(function(response) {

angular.forEach(response.object,function(child) {

console.log(child.object);
});
});
});

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

  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}

});
});

}());

here is the json link i am trying to retrieve

the above link is a json of xml file below

http://www.alsharq.net.sa/feed

please correct my java code to fetch data from the json url provided i wokring on it from last 2 day but could not figure out

Tank U in advance


#2

Do you get any errors?
What exactly is not working?
What did you try before?

Also: Please post the output of ionic info so we know a bit about your versions and environment.


#3

no erros showing when i check the dev console in chrome

please check the code for http is it correct with json link i provided

Tank U


#4

Your $http.get returns an html, not a json.
If you go to network tab, you will see the call that returns JSON is
https://api.rss2json.com/v1/api.json?rss_url=http%3A%2F%2Fwww.alsharq.net.sa%2Ffeed&_=1492369408966

You have to call this on $http.get to get the JSON response


#5

Ah now it is the json response

i will test with my app viewer

Thank You and a nice day

if i need help i will post again