im just starting to learn angular and ioninc to build an application.
I just started a new application with ion turned on and made a list of items from a json file. This works fine, but since im jumping into routing, I just see a blank page, and I'm not mistaken.
this is my index.html:
<!DOCTYPE html> <html > <head> <meta charset="utf-8"> <title>Spätifinder</title> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <link rel="stylesheet" href="css/ionic.css"> <script src="angular.min.js"></script> <script src="js/ionic.bundle.js"></script> <script src="app.js"></script> </head> <body ng-app="spaetifinder"> <ion-header-bar type="bar-positive" animation="nav-title-slide-ios7" back-button-type="button-icon" back-button-icon="ion-ios7-arrow-back"></ion-header-bar> <ion-nav-bar class="bar-energized nav-title-slide-ios7"> </ion-nav-bar> <ion-nav-view></ion-nav-view> </body> </html>
This is the ma app.js file:
var app = angular.module('spaetifinder', ['ionic']); 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 controller can be found in controllers.js $stateProvider .state('home', { url: '/', templateUrl: 'home.html' }); // if none of the above states are matched, use this as the fallback $urlRouterProvider.otherwise('/home'); }); app.controller('StoreController', [ '$http', function($http) { var store = this; store.storeList = [ ]; $http.get('http://m.xn--sptifinder-r5a.de/apiv1/jsonp.php?action=list&lat=52.437595&long=12.987900&distance=100').success(function(data){ store.storeList = data; }); this.loadImage = function(hasImage){ if(hasImage = 0) { return "http://www.spätifinder.de/images/fotos/no-foto.jpg"; } else { return this.ID; } }; }]);
and this should be my template for home (home.html)
<ion-list> <a href="#" class="item item-thumbnail-left" ng-repeat="spaeti in spaetis.storeList"> <img ng-if="spaeti.has_image == 0" ng-src="http://www.spätifinder.de/images/fotos/no-foto.jpg"> <img ng-if="spaeti.has_image == 1" ng-src="http://www.spätifinder.de/images/fotos/{{spaeti.ID}}_crop.jpg"> <h2>{{spaeti.Name}}</h2> <p>{{spaeti.BusinessHours}}<br>{{spaeti.Street}}, {{spaeti.ZIP}} {{spaeti.City}}</p> </a> </ion-list>
I just don’t understand what’s wrong with this, maybe you see an error there?
early
Luc
angularjs angular-ui-router ionic-framework
Linucs
source share