gpt4 book ai didi

angularjs - ionic : Routing gives a blank page

转载 作者:行者123 更新时间:2023-12-04 08:34:55 26 4
gpt4 key购买 nike

我刚刚开始学习 angular 和 ioninc 来构建一个应用程序。

我刚刚启动了一个包含 ionic 的新应用程序,并从 json 文件中创建了一个项目列表。这很完美,但由于我跳入路由,我只看到一个空白页面,我没有弄错。

这是我的 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>

这是 ma app.js 文件:
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's 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;
}
};
}]);

这应该是我的家模板(home.html)
<!-- our list and list items -->
<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>

我只是不明白这有什么问题,也许你看到那里有错误?

提前致谢

卢克

最佳答案

我认为您的问题在于您的路由配置。您只在 / 处定义一种状态网址。然后,您将回退设置为 /home这是不存在的。您可能希望您的家乡位于 /home .

关于angularjs - ionic : Routing gives a blank page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23693121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com