dongyupan4850 2016-07-11 06:59
浏览 20
已采纳

如何使用angularJS和php在单独的页面中显示特定表的更多详细信息

This is My database

This is my html page

I used ng-repeat and was able to display the data in the database. I want to display more information of a perticular table when "Know more" button is clicked in a seperate popup page. how can i achieve this in angularjs ?

.controller('far_req_disp', function($scope, $http) {
  $http.get('php/far_req_disp.php')
    .success(function(data) {
      $scope.request = data;
    })
    .error(function() {
      $scope.error = "error";
    });
})
<div ng-controller="seller_post_disp">
  <ion-list ng-repeat="a in usr007">
    <h2>{{a.crop_id}}</h2>
    <p>Villiage:{{a.village}} & District :{{a.DIST}}</p>
    <p>Expected Price:{{a.expec_price}} {{a.Per}}</p>

    <p>Date of availability:From {{a.from_date}} To {{a.to_date}}</p>
    <a class="button" ng-click="knowMore()">Know More </a>
  </ion-list>
</div>

</div>
  • 写回答

1条回答 默认 最新

  • drxd54816 2016-07-11 07:30
    关注

    Just pass your data object to your knowmore function like this:

    <a class="button" ng-click="knowMore(a)">Know More </a>
    

    1) And Catch that data in your function like:

    $scope.knowmore = function(data){
        console.log(data); // 
    };
    

    2) Else if you use in a separate page for details, broadcast your object and catch it like this.

    $scope.knowmore = function(data){
        $scope.$broadcast('seller_post, data);
    };
    

    Using $scope.$broadcast will fire an event down the $scope. Using $scope.$on is how we listen for these events. Now you can use it across controllers via catch up the "loadPost" event.

    // listen for the event in the relevant $scope
    $scope.$on('seller_post', function (event, data) {
       console.log(data); 
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻看一个题
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)