您知道为什么Angularjs不会更新div吗?但是我能够将数据记录到控制台。

我在这里想念什么?

我加了一个小提琴;

function jsonp_example($scope, $http) {
    $scope.doRequest = function() {
        var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=JSON_CALLBACK";

        $http.jsonp(url)
            .success(function(data){
                console.log(data.found);
            });
    };

}


http://jsfiddle.net/a4Rc2/850/

最佳答案

您需要将结果数据分配给范围变量:

$http.jsonp(url).success(function (data) {
    $scope.data = data;
    console.log(data.found);
});


否则,Angular不知道您希望此响应数据显示在任何地方。

演示:http://jsfiddle.net/a4Rc2/853/

10-08 07:35
查看更多