我正在AngularJS环境中工作。
我有下表转换为ng-repeat
的图表图像。
我设法只分配了要显示的记录,但使用下面的GadgetIconsCtrl
。现在,我需要在每行显示两个<td>
元素。
如何使用<td>
每行显示两个ng-repeat
元素?
<table id="gadgets" class="propertyTable clickable_row">
<tr>
<th>Type</th>
</tr>
<tr>
<td data-url="chart_treelist">
<img data-draggable id="chart_treelist" src="images2/table.png" title="Tree Grid" alt="Hierarchy Grid" width="64" height="64">Grid
</td>
<td data-url="{chart_pivot}">
<img data-draggable id="chart_pivot" src="images2/pivottable.png" title="Pivot Table" alt="Pivot Table" width="64" height="64">Pivot
</td>
</tr>
</table>
当用户启动嵌入该表的模式窗口时,我需要立即突出显示特定的
<td>
元素。这是一些
$scope.widgets
图表属性的示例:$scope.widgets[0].title = "Bar Chart"$scope.widgets[0].gadgetType = "chart"$scope.widgets[0].chartType = "bar"
到目前为止,我正在使用
ng-repeat
,但是在应用filter
时遇到了麻烦这是
ng-repeat
及其附加的控制器:(function () {
'use strict';
angular.module('rage')
.controller('GadgetIconsCtrl', ['$rootScope', '$scope', icons]);
function icons($rootScope, $scope) {
var gadicons = this;
gadicons.widgetSubset = null;
if ($scope.widget.gadgetType == 'chart' && $scope.widget.chartType == 'bar') {
gadicons.widgetSubset = _.filter($scope.widgetDefs, function (item) {
return item.chartType == 'bar' || item.chartType == 'column';
});
}
}; // end of gridSettings()
})();
<table ng-controller="GadgetIconsCtrl as gadicons">
<tr ng-repeat="widget in gadicons.widgetSubset" ng-class="" >
<td>
<img data-draggable ng-src="{{widget.initImage}}" title="{{widget.title}}" alt="Hierarchy Grid" width="64" height="64">{{widget.title}}
</td>
</tr>
</table>
非常感谢您的建议。
问候,
鲍勃
最佳答案
抱歉,我之前给出了错误的答案。因此,您想根据您的范围更改过滤器类型。这是一个基本的小提琴,可以帮助您抽象答案。如果您想获得更多的角度帮助,如果有兴趣,请在我的网站上向我发送一封电子邮件,我想谈谈更多有关角度的信息。
工作提琴https://jsfiddle.net/E6aMZ/26/
<div ng-repeat"thing in things | filter:myThings"></div>