Wordpress Rest Api离子app加载

时间:2015-09-24 00:25:11

标签: angularjs wordpress cordova rest ionic

我正在使用Wordpress REST API和Jetpack开发Wordpress Ionic应用程序。我遵循了教程Hybrid Mobile Application with Ionic/Cordova,但遇到了一个丑陋的问题。当我在library(ggplot2) x <- seq(0,10,.1) y <- as.matrix(cbind(rnorm(101,x,1),rep(x,length(x)),rep(1,length(x)))) z <- as.matrix(cbind(rnorm(101,x+3,1),rep(x,length(x)),rep(0,length(x)))) # move the matrix to a df data <- as.data.frame(rbind(y,z)) # give it some names to make life easier names(data) <- c("Y","Z","X") # note the benefit to qplot as well qplot(y=data$Y,x=data$Z,col=data$X) ggplot(data) + aes(x=data$Z, y=data$Y, col=as.factor(data$X)) + geom_point() + stat_smooth(method = "lm", se = FALSE) 中输入我的REST API链接并在我的浏览器中尝试时,它会像这样继续加载:

http://imgur.com/gallery/6lqUK2M/

另一方面,Freshy-Pressed Api有效,但我不知道为什么。

以下是我正在使用的HTML和JavaScript:

$http.get()
var FPApp = angular.module("FPApp", ["ionic"]);

FPApp.service("FPSvc", ["$http", "$rootScope", FPSvc]);

FPApp.controller("FPCtrl", 
    ["$scope", "$sce", 
     "$ionicLoading", "$ionicListDelegate", "$ionicPlatform",
     "FPSvc", FPCtrl]);

function FPCtrl($scope, $sce, $ionicLoading, $ionicListDelegate, $ionicPlatform, FPSvc) {

    $ionicLoading.show({template: "Loading blogs..."});

    $scope.deviceReady = false;

    $ionicPlatform.ready(function() {
        $scope.$apply(function() {
            $scope.deviceReady = true;
        });
    });

    $scope.blogs = [];
    $scope.params = {};

    $scope.$on("FPApp.blogs", function(_, result) {
        result.posts.forEach(function(b) {
            $scope.blogs.push({
                name: b.author.name,
                avatar_URL: b.author.avatar_URL,
                title: $sce.trustAsHtml(b.title),
                URL: b.URL,

                featured_image: b.post_thumbnail.URL
            });
        });

        $scope.params.before = result.date_range.oldest;

        $scope.$broadcast("scroll.infiniteScrollComplete");
        $scope.$broadcast("scroll.refreshComplete");
        $ionicLoading.hide();
    });

    $scope.loadMore = function() {
        FPSvc.loadBlogs($scope.params);
    }
    $scope.reload = function() {
        $scope.blogs = [];
        $scope.params = {};
        FPSvc.loadBlogs();
    }

    $scope.show = function($index) {
        cordova.InAppBrowser.open($scope.blogs[$index].URL, "_blank", "location=no");
    }
    $scope.share = function($index) {
        $ionicListDelegate.closeOptionButtons();
        window.socialmessage.send({
            url: $scope.blogs[$index].URL
        });
    }

}

function FPSvc($http, $rootScope) {
    this.loadBlogs = function(params) {
        $http.get("https://public-api.wordpress.com/rest/v1/sites/100060382/posts/", {
                params: params})
            .success(function(result) {
                $rootScope.$broadcast("FPApp.blogs", result);
            });
    }
}

如何解决此问题?

0 个答案:

没有答案