2017-08-14 32 views
0

我试图制作一个具有表格的网页,并且用户必须能够点击已过滤的行或未经过滤的行,并弹出一个模式显示有关所选行的更多信息。从HTML表格行中获取值并将它们传递给模式

这里是主代码(包括表)

<body ng-app="mainApp"> 
<h1>Issues Repository</h1> 
<div class="container-1"> 
<span class="icon"><i class="fa fa-search"></i></span> 
<input type="search" id="search" ng-model="searchBox" placeholder="Buscar..." /> 
</div> 
<div> 


</div> 
<div id="divBuscador" ng-controller="issues"> 
    <table class="table table-striped" id="tableList" cellspacing="0" border=1> 

    <tr> 
     <th>OpCo</th> 
     <th>Tecnologia</th> 
     <th>Version</th> 
     <th>Titulo del Issue</th> 
     <th>Estado</th> 
    </tr> 

     <tr class='clickable-row' data-target="#contentModal" style="cursor:pointer" id="issueList" ng-repeat="document in documents | filter:searchBox" ng-click="openModal(documents)"> 
     <td id="opCo_Val">{{ document.opCo}}</td> 
     <td id="tec_Val">{{ document.Tecnology }}</td> 
    <td >{{ document.Version }}</td> 
    <td >{{ document.Issue }}</td> 
    <td >{{ document.Status }}</td> 
     </tr> 
    </table> 

</div> 

这是链接到功能上的点击:

jQuery(document).ready(function($) { 
      $(".clickable-row").click(function() { 
       $('#contentModal').modal('show'); 
     }); 
     }); 

这是控制器:

app.controller('issues', ['$scope', function($scope, $modal){ 
$scope.documents = fileX.records; 

}]); 

我怎样才能将变量传递给模态,如{{document.Version}}或{{document.Issue}}

请解释一切,我新来角。

+0

@PankajParkar请解释一下你自己......我不知道如何应用ng-click – Marcelo

+0

你有没有尝试使用类似ui-bootstrap的库它具有惊人的模态解释如何传递数据。 –

回答

0

据我所知,你需要从点击行获取数据?

下面的这段代码会帮你。

$('#example tr').click(function(){ 
      $(this).find("td").each(function(){ 
      alert($(this).html()); 
     }); 
    }); 

我已经在警告框中打印了值,它完美地工作。如果要存储的每个值阵列只是这个代码行推:

$scope.tableRowValues = []; 
    $scope.tableRowValues.push($(this).html()); 

。每个方法的内部

希望这将帮助你!

+0

我自己找到了解决方案,但感谢您的回答,无论如何,我需要一些关于在数组中存储值的解释,您能帮我解决吗? – Marcelo

+0

用上面的命令push,你将数组中的每一个对象的值存储起来 –

0

从来就发现了这个问题的解决,删除上述的jQuery的,加入这个控制器:

$scope.openModal=function (index, ob) 
    { 
    $scope.id=index; 
    $scope.selected_issue=ob; 
    } 

而且也从来就一套NG点击和数据目标到行:

<tr style="cursor:pointer" id="issueList" ng-repeat="issues in issue | filter:searchBox" ng-click="openModal($index, issues)" data-toggle="modal" data-target="#contentModal"> 

感谢大家帮助!

相关问题