我刚接触到JSON,我尝试使用$http get
of AngularJS从存储在项目位置的文件中获取JSON数据,但是它返回的cannot read property 'get' of undefined
.I在我的函数中注入了$http,但它的抛出错误我的代码是
function eventController($scope, $http) {
var baseurl = window.location.href;
var url = baseurl+"Json/data.json";
$http.get(url).success(function (response) {
$scope.talks = response;
});
}
eventController.$inject = ['$scope'];
请任何人指指我做错了什么
发布于 2015-12-23 06:57:05
您必须注入$http
,然后只有您才能在eventController中获得$http
eventController.$inject = ['$scope','$http'];
https://stackoverflow.com/questions/34430240
复制相似问题