【发布时间】:2015-07-02 14:51:29
【问题描述】:
我在 cellTemplate ng-click 后使用 ng-repeat 填充表格时遇到问题。
cellTemplate: '<div ng-click="foo()" ng-bind="row.getProperty(col.field)"></div>'
在这个 foo 方法中,我试图将结果传递给 html 页面。
$scope.results = $scope.source;
$scope.foo = function(ngClickResult) {
$scope.showNgClick = this.result;
$scope.ngClickResults = ngClickResult;
$scope.source 在这里定义。
angular.forEach($scope.items, function (item) {
if(item.fname === enteredValue.firstName ){
arrItem.push({
first: item.fname,
last: item.lname,
address: item.address,
phone: item.phone
});
}
});
$scope.source= arrItem;
html
<tr data-ng-repeat="ngClickResult in ngClickResults">
<td>First Name:{{showNgClick.firstName}}</td>
<td>Last Name:{{showNgClick.lastName}}</td>
<td>Address:{{showNgClick.address}}</td>
<td>Phone:{{showNgClick.phone}}</td></tr>
有些东西告诉我这是我的结果/来源。我错过了什么?
这里是plnkr
搜索 Tim 以启动搜索。
我的目标是使用 NG 网格中显示的数据填充 NG Click Results 下的表格。我想在 NG Click Results 下显示名字、姓氏、地址和电话。我希望 ng 单击列出与在网格中选择的行关联的所有数据。例如:点击第一行,显示第一行的数据。点击第二行,显示第二行数据等
【问题讨论】:
-
我认为您正朝着正确的方向前进,但这里的最终目标尚不清楚。你想让你的网格做什么?你想让它列出你在网格中选择的所有行吗?
-
ng-click 与这些有什么关系?您是否正在尝试制作“可点击”项目的表格?你也没有明确说明你的问题是什么。
-
感谢您的反馈。很抱歉模棱两可。问题已更新。
-
所以每当用户单击另一行时,您都会将该选择添加到底部的表格中?
-
是的。这就是我想要实现的目标。
标签: javascript angularjs angularjs-scope angularjs-ng-repeat angular-ngmodel