【发布时间】:2016-06-23 00:12:36
【问题描述】:
这是我的角度控制器:
.controller( 'QuestionsController', function( $scope, $state, $http, $ionicSlideBoxDelegate, $q ) {
var answer = null; // global answer variable
var totalScore = 0; // global totalScore variable
$scope.init = function() {
// the question number
$scope.questionNumber = 1;
$scope.getQuestions().then( function( res ) {
alert( res );
$scope.questionList = res;
}, function( err ) {
alert( err );
console.log( status );
})
};
// this fetches the questions from the json data source.
$scope.getQuestions = function() {
var defer = $q.defer();
$http.get( 'data/data.json' ).success( function( data ) {
defer.resolve( data );
}, function( status ) {
defer.reject( status );
});
return defer.promise;
};
我已尝试将 json 文件路径替换为以下内容,但仍然无法正常工作:
$http.get('file:///android_asset/www/data/data.json')
$http.get('./data/data.json')
我真的需要帮助,并且在 android 版本 5.1 (Lollipop) 上运行
【问题讨论】:
-
你的文件结构是什么?
标签: android angularjs json cordova ionic-framework