【问题标题】:How to get a state of filtered array?如何获得过滤数组的状态?
【发布时间】:2019-11-30 11:54:07
【问题描述】:

我有一个表格,里面有一组用管道过滤的对象。我想获得过滤内容的实际状态,而不是将其作为组件中的变量。有可能吗?
假设我有一张桌子:

<tr *ngFor="let obj of objects | filter:inputVal">
    <td>{{obj.foo}}</td>
    <td>{{obj.bar}}</td>
</tr>

我想通过以下条件禁用按钮:

<button type="button" (ng-disabled)="(objects | filter:inputVal).length != 1">Remove</button>

【问题讨论】:

    标签: angular pipe


    【解决方案1】:

    语法是[disabled]

    试试这样:

    <button type="button" [disabled]="(objects | filter:inputVal).length != 1">Remove</button>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-31
      • 2015-09-18
      • 1970-01-01
      • 2021-03-26
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      相关资源
      最近更新 更多