就像标题所说,我正在开发使用Phonegap + Ionic的混合应用程序。我有一些angularjs代码,数据在浏览器中完美呈现,但是当我在Genymotion(或在真实手机中)测试应用程序时,不会出现。
这是html部分:
<div class="wod-content-training padding-h4">
<div ng-repeat="sport in training.exercises" class="training no-padding clear-fix roboto-l">
<div class="icon-full w-12" ng-class="sport.image"></div>
<div class="font-9pt relative flexcenter-h-v w-14">{{sport.count}}</div>
<div class="text-right font-9pt relative text-vcenter w-52">< {{sport.name}} ></div>
<div class="icon-full whiteblue-eye w-08"></div>
</div>
</div>
告诉我你是否需要关于angularjs代码的东西,但我认为根本不重要。因为这些代码正在浏览器中运行,所以问题就是关于PhoneGap(或Cordova)的问题。
这是一个图片示例,展示了浏览器中html部分的显示方式:
移动设备只是空的。
有人对此有所了解吗?可能是什么问题?对不起,如果我的英语不完美。
提前致谢
更新
以下是了解我如何获得运动部分的角度:
app.factory('trainingExercises', ['$q', '$timeout', '$http', function($q, $timeout, $http) {
var exercises = {
fetch: function() {
var deferred = $q.defer();
$timeout(function() {
$http.get('/resources/training.json').success(function(data) {
deferred.resolve(data);
});
}, 30);
return deferred.promise;
}
}
return exercises;
}]);
app.controller('freeWODController', ['$scope', '$location', 'trainingExercises', function($scope, $location, trainingExercises) {
$scope.pageTitle = 'WOD Libre';
trainingExercises.fetch().then(function(data) {
$scope.training = data;
});
}]);
和 training.json :
{
"exercises": [
{
"name": "Overhead squat",
"image": "green-overhead-squat",
"count": "10"
},
{
"name": "Ring dip",
"image": "whiteblue-ring-dip",
"count": "10"
},
{
"name": "Toes to bar",
"image": "blue-toes-to-bar",
"count": "20"
},
{
"name": "Ring dip",
"image": "whiteblue-ring-dip",
"count": "10"
},
{
"name": "Toes to bar",
"image": "blue-toes-to-bar",
"count": "20"
}
]
}
更新2:
感谢 jcesarmobile 推荐我GapDebug工具,这非常适合通过PhoneGap调试应用,并且也可以使用Genymotion!
所以现在我遇到了什么问题,但根本不知道如何解决这个问题。这一行:
$http.get('/resources/training.json')
那是在www / js / app.js中,training.json在www / resources / training.json中,所以我试过了:
$http.get('../resources/training.json')
但没有。在GapDebug中,我可以看到training.json的FILE_NOT_FOUND,因为尝试获取的位置路径是: file:///android_asset/resources/training.json
如何在app.js中正确设置位置路径?
谢谢!