我的js文件是,
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http) {
$http.get('js/countries.json').success(function (data) {
$scope.countries = data;
});
});
当我在我的Android手机上模仿它时它很好。但在我的Chrome浏览器中,在Windows 7下运行不会加载json。请帮帮我......
答案 0 :(得分:0)
您应该使用.then
来解析request
。代码段:
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http) {
$scope.countries - {};
var promise = $http.get('js/countries.json');
promise.then(function (data) {
$scope.countries = data;
}), function(reason) {
//on error - use $log is better
console.log('Failed: ' + reason);
};
});