I am new to AngularJS, I am trying to get JSON data from a file stored in my project location using $http get
of angular but its returning cannot read property 'get' of undefined
.I am injecting $http in my function still its throwing error my code is
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'];
Kindly anyone point me what I am doing wrong
您必须注入$http
,然后只有您可以在eventController中获得$http
。
eventController.$inject = ['$scope','$http'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.