Hello,
I try to display some data via $http in my app. A php file is receiving the data from the database encodes it to JSON. But at the end, my ion-item element in the tab-search.html is empty. But receiving the data was succesful. I can see it in the console of my browser. Hope you can understand my problem.
Here’s my code.
tab-search.html
<ion-content class="has-subheader">
<ion-list>
<ion-item ng-href="#" ng-repeat="angebot in angebote">
<img ng-src="{{ angebot.titelbildUrl }}" class="full-width">
<h2>{{ angebot.titel }}</h2>
<p>{{ angebot.beschreibung }}</p>
</ion-item>
</ion-list>
</ion-content>
controller.js
var app = angular.module('starter');
app.controller('angeboteCtrl', function($scope, $http){
load();
function load() {
$http.get('http://www.siregar.net/testing/eventAppBackend/getAngebote.php').success(function(response) {
console.log(response);
$scope.angebote = response.data;
});
};
app.js
var app = angular.module('starter', ['ionic'])
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleLightContent();
}
});
})
app.config(function($stateProvider, $urlRouterProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.search', {
url: '/search',
views: {
'tab-search': {
templateUrl: 'templates/tab-search.html',
controller: 'angeboteCtrl'
}
}
})
.state('tab.details', {
url: '/search/:angebotId',
views: {
'tab-details': {
templateUrl: 'templates/tab-details.html',
controller: 'angeboteCtrl'
}
}
})
.state('tab.profile', {
url: '/profile',
views: {
'tab-profile': {
templateUrl: 'templates/tab-profile.html'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/search');
});