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

0

1 Answer 1

-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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.