Unable to show post list using http result :( Console does show up the result


#1

Hi Experts,

Just started to explore ionic but stuck here .

I want to bring the posts from wordpress custom post type my list works fine when i output the result to console.

$rootScope.url = http://cookingshooking.com

My controller.js

.controller('EventsCtrl', function($scope, $http, $rootScope){
	$scope.events=[]
	$http
			.get($rootScope.url + '/wp-json/posts?type=slider', {cache:true})
			.then(function(response) {
			$scope.events = response.data.results;
			// console.log(response)  //<--This Actually prints the result on my console
			});	

}) 

My html

    <ion-view view-title="Events">
  <ion-content>
  	<ion-list>
		<ion-item ng-repeat="event in events" href="#/app/events/{{event.id}}">
			<h3>{{event.title}}</h3>
			
		</ion-item>
	</ion-list>

	
  </ion-content>
</ion-view>

my app.js

  .state('app.events', {
    url: "/events",
    views: {
      'menuContent': {
        templateUrl: "templates/events.html",
        controller: 'EventsCtrl'
      }
    }
  })

#2

Looking at the data returned by that URL that should be just response not response.data.results.


#3

Thank you very much. your suggestion helped me. “response.data” is bringing required data.