小编use*_*428的帖子

多个返回的密钥json

我有一个运行k2的joomla网站,并通过在字符串末尾添加format = json来从中提取信息:https://www.example.com/posts? format = json ,输出如下内容:

{
site: {
      url: "https://www.example.com",
      name: "mySite"
      },
category: {
          id: "67",
          name: "Gauteng",
          alias: "gauteng",
          link: "/tna/provincial/gauteng.html",
          parent: "66",
          extraFieldsGroup: "0",
          image: null,
          ordering: "1",
        events: {
          K2CategoryDisplay: ""
        },
        chidlren: []
       },
items: [{ 
         id="1",
         title="The Title",
         body="body content here..."
        },
        { 
         id="2",
         title="The Title",
         body="body content here..."
        }
}
Run Code Online (Sandbox Code Playgroud)

现在我正在为此创建一个服务,只想访问"项目".

.factory('Posts', function($http) {

  var posts = [];

  return {
        getPosts: function(){
            return $http.get("https://www.example.com/posts?format=json").then(function(response){
                posts = response;
                return …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-factory angularjs-http ionic-framework

1
推荐指数
1
解决办法
54
查看次数