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

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -