javascript - Not getting json data from json-angularjs call to an external url with $http.get using success method -
controller.js file code:
var myapp=angular.module('myapp',[]); myapp.controller('mycontroller', function($scope,$http){ $http.get('data.json').success(function(data){ $scope.art=data; }); });
you have assign response $scope.art
var myapp=angular.module('myapp',[]); myapp.controller('mycontroller', function($scope,$http){ $http.get('data.json').success(function(response){ $scope.art=response; }); });
note : deprecated .success , .error methods have been removed angularjs 1.6
using .then
var myapp=angular.module('myapp',[]); myapp.controller('mycontroller', function($scope,$http){ $http.get('data.json').then(function(response){ $scope.art=response.data; }); });
Comments
Post a Comment