Controller.js文件代码:
var myApp=angular.module('myApp',[]);
myApp.controller('myController', function($scope,$http){
$http.get('data.json').success(function(data){
$scope.art=data;
});
});
答案 0 :(得分:2)
您必须将回复分配给$scope.art
var myApp=angular.module('myApp',[]);
myApp.controller('myController', function($scope,$http){
$http.get('data.json').success(function(response){
$scope.art=response;
});
});
注意:已弃用的.success和.error方法已从AngularJS 1.6中删除
使用.then
var myApp=angular.module('myApp',[]);
myApp.controller('myController', function($scope,$http){
$http.get('data.json').then(function(response){
$scope.art=response.data;
});
});
答案 1 :(得分:2)
var myApp=angular.module('myApp',[]);
myApp.controller('myController', function($scope,$http){
$http.get('data.json').then(function(response){
$scope.art=response.data;
});
});
尝试以上。可能会帮助!!