如何解决应用于表中搜索的异步管道中的错误?

发布时间:2020-07-07 16:23

在这里,我尝试在angular中使用ng-bootstrap在表中应用searchinh,异步管道中出现错误“ InvalidPipeArgument:'[object Object],[object Object],[object Object],[object Object],[object对象]'用于管道'AsyncPipe'“。我在ng-bootstrap网站上做的完全相同。

这是我的HTML表格,在这里我已申请过滤。

<table class="table table-striped">
  
          <thead class="thead-dark">
  
            <tr>
              <th>S.No.</th>
              <th>Name</th>
              <th>Email</th>
              <th>Date Of Birth</th>
              <th>Contact Number</th>
              <th>Image</th>
              <th>Action</th>
              
            </tr>
          </thead>
  
          <tbody>
            <tr *ngFor="  let recentDetails of user$ | async; index as i ">
              <td >{{i+1+((tableModel.Page-1)*tableModel.pageSize)}}</td>
              <td ><ngb-highlight [result]="recentDetails.name" [term]="filter.value"></ngb-highlight></td>
              <td ><ngb-highlight [result]="recentDetails.email" [term]="filter.value"></ngb-highlight></td>
              <td ><ngb-highlight [result]="recentDetails.dateOfBirth" [term]="filter.value"></ngb-highlight></td>
              <td ><ngb-highlight [result]="recentDetails.contactNumber" [term]="filter.value"></ngb-highlight></td>
              <td><img src="https://localhost:44342/Images/{{recentDetails.userImageGuid}}"></td> 
              <td> <button class="btn btn-warning" (click)="editUserDetails(recentDetails.email)">Edit</button> &nbsp;
                <button class="btn btn-danger" (click)="deleteRow(recentDetails.id,i)">Delete</button>
              </td>
            </tr>
          </tbody>

现在这是一个搜索功能

function search(text: string): User[] {
  return this.user$.filter(user => {
    const term = text.toLowerCase();
    return user.name.toLowerCase().includes(term)
  });
}

能否请您帮我解释为什么异步获取[object,object] 在ng-bootstrap网站上做了同样的事情,但是没有错误

谢谢。

回答1