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); 
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行