首页 > 解决方案 > 为什么异步管道“InvalidPipeArgument: '[object Object],[object Object],' for pipe 'AsyncPipe'”中有错误?

问题描述

我正在尝试通过 ng-bootstrap 在表中应用搜索。但是异步管道中有一个错误 ="InvalidPipeArgument: '[object Object],[object Object],[object Object],[object Object],[object Object]' for pipe 'AsyncPipe'" 我已应用与显示在 ng-botstrap 网站上。

 <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>
        </table>

请帮帮我。提前谢谢。

标签: htmlangulartypescriptbootstrap-4ng-bootstrap

解决方案


听起来像是user$对象数组,而不是对象数组的可观察对象。如果是这种情况,您可以删除| async并且无论如何它都应该工作。

如果你需要user$成为一个 observable,你将不得不重新检查你的 Typescript 代码。此外,如果您需要这方面的帮助,您也应该分享相关的 TS 代码片段。


推荐阅读