通过模式或表格显示json数据和ng-click

时间:2018-03-08 17:15:58

标签: angularjs angularjs-ng-click

在显示json conect时需要帮助。当我按下用户名时,我需要在模态或表格中显示特定的用户详细信息。关于如何使用onclick做任何建议?

         var mainApp= angular.module("mainApp", []);

    mainApp.controller('TableFilterController', function($scope) {
   $scope.clickMe = function(p) {
        $scope.selected = p;
    }

    $scope.isSelected = function(p) {
        return $scope.selected === p;
    }
      $scope.details = [
        {
          name : 'Mercury',
          age : 0.4,
          mass : 0.055,
          descp : 'it is the hottest planet',
        },

https://plnkr.co/edit/FluJQRlTkdsNfv1NLDhW?p=preview

1 个答案:

答案 0 :(得分:1)

您可以使用 $modal 引导程序弹出一个dilaog框,

 $modal.open({
      templateUrl: 'myModalContent.html',
      backdrop: true,
      windowClass: 'modal',
      controller: function($scope, $modalInstance, $log) {
        $scope.selected = p;
        $scope.submit = function() {
          $log.log('Submiting user info.');
          $log.log($scope.selected);
          $modalInstance.dismiss('cancel');
        }
        $scope.cancel = function() {
          $modalInstance.dismiss('cancel');
        };
      },
      resolve: {
        user: function() {
          return $scope.selected;
        }
      }
    });

<强> DEMO WITH PLUNKER