我正在学习如何使用Ionic,目前正在使用localhost来测试应用程序。我正在尝试构建联系人列表应用程序,并从JSON文件加载联系人信息,如姓名,电子邮件,联系电话号码和头像。但没有任何显示,控制台中的Chrome错误消息说:“无法加载资源:服务器响应状态为404(未找到)”
这是我的index.html文件:
{% url 'galleries-view-gallery-paginator' gallery.slug page_obj.next_page_number %}
这是我的app.js文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<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>
</head>
<body ng-app="starter">
<ion-pane ng-controller-"myController">
<ion-header-bar class="bar-dark">
<button class="button button-clear icon ion-navicon"></button>
<h1 class="title">Friends List</h1>
<button class="button button-clear icon ion-settings"></button>
</ion-header-bar>
<div class="bar bar-subheader item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" placeholder="Search"/>
</label>
</div>
<ion-content class="has-subheader">
<div class="list">
<div class="item item-thumbnail-left" ng-repeat="element in data.persons">
<img src="{{ element.personDisplayPicture }}"/>
<h2>{{ element.personName }}</h2>
<p>{{ element.personContact }}</p>
<p>{{ element.personEmail }}</p>
</div>
</div>
</ion-content>
</ion-pane>
</body>
</html>
我的addressbook.json文件位于“js”文件夹中,我的app.js文件也位于该文件夹中。 addressbook.json文件只使用了一些示例信息:
angular.module('starter', ['ionic'])
.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();
}
});
})
.controller('myController', function($scope,$http){
$http.get('js/addressbook.json').success(function(data){
$scope.data = data;
})
})