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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -