Javascript Onsen angular js api调用

Javascript Onsen angular js api调用,javascript,angularjs,onsen-ui,Javascript,Angularjs,Onsen Ui,我不知道这是否是一个角度问题。无论如何,我正在为我的移动应用程序使用onsen ui,我需要一种方法从一个页面转换到另一个页面,并在这些页面之间共享数据。下面是我的app.js代码 // Wordpress Posts Controller var app = angular.module('myApp', []); app.controller('PostsController', function($scope, $http, PostsData) { $http({method:

我不知道这是否是一个角度问题。无论如何,我正在为我的移动应用程序使用onsen ui,我需要一种方法从一个页面转换到另一个页面,并在这些页面之间共享数据。下面是我的app.js代码

// Wordpress Posts Controller
var app = angular.module('myApp', []);
app.controller('PostsController', function($scope, $http, PostsData) {

    $http({method: 'GET', url: 'http://akufoaddo2016.com/api/get_recent_posts/'}).
    success(function(data, status, headers, config) {
        $scope.posts = data.posts;

    }).
    error(function(data, status, headers, config) {

    });

    $scope.showDetail = function(index) {
    var selectedItem = $scope.posts[index];
    PostsData.selectedItem = selectedItem;
    $scope.ons.navigator.pushPage('page4.html', selectedItem);
    }

});
我想显示数据的页面是page4.html,下面是代码

<ons-page ng-controller="PostsController">
<ons-toolbar style="background-color: #132e42" >
            <div class="left">
                <ons-toolbar-button ng-click="app.slidingMenu.toggleMenu()"><ons-icon icon="ion-android-more-vertical" style="color: #fff"></ons-icon></ons-toolbar-button>
            </div>
            <div class="center" style="font-weight:bold; color:#fff;">Nana Akuffu Addo</div>             
        </ons-toolbar>

    <ons-scroller>

        <div  ng-app="myApp" ng-repeat="post in posts">
        <ons-row >
        <h3 class="title" ng-click="showDetail($index)">{{post.title}}</h3>
        <p>{{post.excerpt}}</p>
        </ons-row>
        </div>

    </ons-scroller>

</ons-page>

娜娜·阿库夫·阿多
{{post.title}
{{文章节选}

我不知道我做错了什么;它不会打印任何值

如果您想知道json数据是什么样子的:

{
  "count": 2,
  "status": "ok",
  "count_total": 2,
  "pages": 1,
  "posts": [
    {
      "id": 4,
      "type": "post",
      "slug": "nana-akufo-addo-visits-pentecost-convention-centre",
      "url": "http://akufoaddo2016.com/2016/01/17/nana-akufo-addo-visits-pentecost-convention-centre/",
      "status": "publish",
      "title": "NANA AKUFO &#8211; ADDO VISITS PENTECOST CONVENTION CENTRE",
      "title_plain": "NANA AKUFO &#8211; ADDO VISITS PENTECOST CONVENTION CENTRE",
      "content": "<p>The Presidential Candidate of the New Patriotic Party (NPP) for the 2016 elections, Nana Addo Dankwa Akufo-Addo, on Friday, January 15, 2016 made a historic visit to the ultra-modern Pentecost Convention Centre (PCC) located at Gomoa Fetteh, near Kasoa.  <a href=\"http://akufoaddo2016.com/2016/01/17/nana-akufo-addo-visits-pentecost-convention-centre/#more-4\" class=\"more-link\">Read more</a></p>\n",
      "excerpt": "<p>The Presidential Candidate of the New Patriotic Party (NPP) for the 2016 elections, Nana Addo Dankwa Akufo-Addo, on Friday, January 15, 2016 made a historic visit to the ultra-modern Pentecost Convention Centre (PCC) located at Gomoa Fetteh, near Kasoa.</p>\n",
      "date": "2016-01-17 23:56:42",
      "modified": "2016-01-17 23:56:42",
      "categories": [
        {
          "id": 2,
          "slug": "blog",
          "title": "Blog",
          "description": "",
          "parent": 0,
          "post_count": 1
        }
      ],
      "tags": [],
      "author": {
        "id": 1,
        "slug": "admin",
        "name": "admin",
        "first_name": "",
        "last_name": "",
        "nickname": "admin",
        "url": "",
        "description": ""
      },
      "comments": [],
      "attachments": [
        {
          "id": 5,
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
          "slug": "akufoaddo-pentecost-jan16",
          "title": "akufoaddo-pentecost-jan16",
          "description": "",
          "caption": "",
          "parent": 4,
          "mime_type": "image/jpeg",
          "images": {
            "full": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
              "width": 430,
              "height": 334
            },
            "thumbnail": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-150x150.jpg",
              "width": 150,
              "height": 150
            },
            "medium": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-300x233.jpg",
              "width": 300,
              "height": 233
            },
            "medium_large": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
              "width": 430,
              "height": 334
            },
            "large": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
              "width": 430,
              "height": 334
            },
            "post-thumbnail": {
              "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
              "width": 430,
              "height": 334
            }
          }
        }
      ],
      "comment_count": 0,
      "comment_status": "open",
      "thumbnail": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
      "custom_fields": {},
      "thumbnail_size": "post-thumbnail",
      "thumbnail_images": {
        "full": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
          "width": 430,
          "height": 334
        },
        "thumbnail": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-150x150.jpg",
          "width": 150,
          "height": 150
        },
        "medium": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-300x233.jpg",
          "width": 300,
          "height": 233
        },
        "medium_large": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
          "width": 430,
          "height": 334
        },
        "large": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
          "width": 430,
          "height": 334
        },
        "post-thumbnail": {
          "url": "http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg",
          "width": 430,
          "height": 334
        }
      }
    },
    {
      "id": 1,
      "type": "post",
      "slug": "hello-world",
      "url": "http://akufoaddo2016.com/2016/01/13/hello-world/",
      "status": "publish",
      "title": "Hello world!",
      "title_plain": "Hello world!",
      "content": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n",
      "excerpt": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n",
      "date": "2016-01-13 21:24:36",
      "modified": "2016-01-13 21:24:36",
      "categories": [],
      "tags": [],
      "author": {
        "id": 1,
        "slug": "admin",
        "name": "admin",
        "first_name": "",
        "last_name": "",
        "nickname": "admin",
        "url": "",
        "description": ""
      },
      "comments": [
        {
          "id": 1,
          "name": "Mr WordPress",
          "url": "https://wordpress.org/",
          "date": "2016-01-13 21:24:36",
          "content": "<p>Hi, this is a comment.<br />\nTo delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.</p>\n",
          "parent": 0
        }
      ],
      "attachments": [],
      "comment_count": 1,
      "comment_status": "open",
      "custom_fields": {}
    }
  ]
}
{
“计数”:2,
“状态”:“确定”,
“总计数”:2,
"页":一,,
“员额”:[
{
“id”:4,
“类型”:“职位”,
“slug”:“nana akufo addo参观五旬节会议中心”,
“url”:”http://akufoaddo2016.com/2016/01/17/nana-akufo-addo-visits-pentecost-convention-centre/",
“状态”:“发布”,
“标题”:“娜娜·阿库福和阿多参观五旬节会议中心”,
“标题平原”:“娜娜·阿库福和阿多参观五旬节会议中心”,
“内容”:“2016年选举新爱国党(NPP)总统候选人娜娜·阿多·丹克瓦·阿库福·阿多于2016年1月15日星期五对位于卡索附近戈莫阿·费特赫的超现代五旬节会议中心(PCC)进行了历史性访问。

\n”, “节选”:“2016年选举新爱国党(NPP)总统候选人娜娜·阿多·丹克瓦·阿库福·阿多于2016年1月15日(星期五)对位于卡索附近戈莫阿·费特的超现代五旬节会议中心(PCC)进行了历史性访问。

\n”, “日期”:“2016-01-17 23:56:42”, “修改”:“2016-01-17 23:56:42”, “类别”:[ { “id”:2, “slug”:“blog”, “标题”:“博客”, “说明”:“, “父项”:0, “后计数”:1 } ], “标签”:[], “作者”:{ “id”:1, “slug”:“admin”, “名称”:“管理员”, “名字”:“, “姓氏”:“, “昵称”:“管理员”, “url”:“, “说明”:” }, “评论”:[…], “附件”:[ { “id”:5, “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “slug”:“akufoaddo-pentecost-jan16”, “标题”:“akufoaddo-pentecost-jan16”, “说明”:“, “标题”:“, “家长”:4, “mime_类型”:“图像/jpeg”, “图像”:{ “完整”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “缩略图”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-150x150.jpg", “宽度”:150, “高度”:150 }, “中等”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-300x233.jpg", “宽度”:300, “高度”:233 }, “中大号”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “大”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “发布缩略图”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 } } } ], “注释计数”:0, “评论状态”:“打开”, “缩略图”:http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “自定义_字段”:{}, “缩略图大小”:“发布缩略图”, “缩略图图像”:{ “完整”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “缩略图”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-150x150.jpg", “宽度”:150, “高度”:150 }, “中等”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16-300x233.jpg", “宽度”:300, “高度”:233 }, “中大号”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “大”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 }, “发布缩略图”:{ “url”:”http://akufoaddo2016.com/wp-content/uploads/2016/01/akufoaddo-pentecost-jan16.jpg", “宽度”:430, “高度”:334 } } }, { “id”:1, “类型”:“职位”, “鼻涕虫”:“你好,世界”, “url”:”http://akufoaddo2016.com/2016/01/13/hello-world/", “状态”:“发布”, “标题”:“你好,世界!”, “世界你好!”, “内容”:“欢迎来到WordPress。这是您的第一篇文章。编辑或删除它,然后开始写作!

\n”, “摘录”:“欢迎来到WordPress。这是你的第一篇文章。编辑或删除它,然后开始写作!

\n”, “日期”:“2016-01-13 21:24:36”, “修改”:“2016-01-13 21:24:36”, “类别”:[], “标签”:[], “作者”:{ “id”:1, “slug”:“admin”, “名称”:“管理员”, “名字”:
angular.module('app').controller('FirstController', function ($scope, $http) { 
  // .. get myData somehow from the page
  navi.pushPage('second-page.html', {myData: myData});
}

angular.module('app').controller('SecondController', function ($scope, $http) { 
   // read the data that that was given by pushPage
   $scope.data =  navi.getCurrentPage().options.myData;
}