2016-12-27 4 views
1

아래 코드를 사용하여 json을 구문 분석하려고했지만 빈 페이지가 표시됩니다.

var app = angular.module('myApp', []); 
app.controller('myCtrl', function($scope, $http) { 
    $http.get("http:krispypapad.herokuapp.com/fetch_article").success(function (response) { 
     $scope.myWelcome = data.response; 

    }); 
}); 
+0

참조 [왜 각 $에 http 성공/오류 방법이되지 않습니다하지 response.data를 사용해야합니까? v1.6에서 제거 되었습니까?] (http://stackoverflow.com/a/35331339/5535245). – georgeawg

답변

1

내가 사용하는 URL에 오타가 있다고 생각 : 대신

http:krispypapad.herokuapp.comhttp://krispypapad.herokuapp.com//

이 코드는 모양을 어떻게 몇 누락 :

var app = angular.module('myApp', []); 
app.controller('myCtrl', function($scope, $http) { 
    $http.get("http://krispypapad.herokuapp.com/fetch_article").success(function (response) { 
     $scope.myWelcome = response; //<-- no .data is required 

    }); 
}); 
+0

'.success' 메소드는 응답 객체를 반환하지 않습니다. 대신에'.then' 메쏘드를 사용하십시오. – georgeawg

0

URL에 오타가 있습니다. 다음과 같아야합니다.

http://krispypapad.herokuapp.com/whatever 

또한 당신은 data.response

+0

'.success' 메소드는 응답 객체를 반환하지 않습니다. 대신에'.then' 메쏘드를 사용하십시오. – georgeawg