0

I cannot run $http on the plunker. Could you help me check my code.

var QuizApp = angular.module('QuizApp', []);

QuizApp.controller('QuizController', ['$scope','$http',function($scope,$http) {

  $scope.message = "hey y'all";

  $http.get('questions.json').success(function(data){
    $scope.questions=data
  });

}]);

https://plnkr.co/edit/sJHwt51k4RPKmq5eT2JF?p=preview

Hai
  • 1

1 Answers1

-1

you need to use .then instead of .success as it was deprecated with the angularjs version above 1.3. You should also use .data to access the actual json response

QuizApp.controller('QuizController', ['$scope', '$http', function($scope, $http) {
  $scope.message = "hey y'all";
  $http.get('questions.json').then(function(data) {
    $scope.questions = data.data;
  });
}]);

PLUNKER DEMO

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396