找到了解决方案:
ES5
var SearchFilter = ng.core.Pipe({
name: "searchFilterTable"
})
.Class({
constructor: function SearchFilter () {},
transform: function(elements, string) {
console.log(elements);
console.log(string);
return elements.filter(
item => item.name.toLowerCase().indexOf(string.toLowerCase()) !== -1);
}
});
html
<tr *ngFor='let gateway of gateways | searchFilterTable:keyword'>
<td class="special-td">{{ gateway.name }}<br><a>(edit)</a></td>
<td class="special-td">{{ gateway.type }}</td>
<td class="special-td">{{ gateway.forwardingAddress }}</td>
<td class="special-td copy">{{ gateway.key }}</td>
<td class="special-td"></td>
</tr>
确保将管道添加到您的声明/导入中