Angular 如何将各个项目的详细信息传递给模式ng2引导?

Angular 如何将各个项目的详细信息传递给模式ng2引导?,angular,ng2-bootstrap,Angular,Ng2 Bootstrap,我正在使用 显示项目的更多详细信息。当我点击相应的项目时,我想将其各自的详细信息显示到模式中 这是我的代码 <table class="table table-hover table-bordered table-striped tableheader"> <thead> <tr> <th>First Name</th> <th>Last Name</th> <th>Ge

我正在使用

显示项目的更多详细信息。当我点击相应的项目时,我想将其各自的详细信息显示到模式中

这是我的代码

<table  class="table table-hover table-bordered table-striped tableheader">
<thead>
  <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Gender</th>
    <th>City</th>
    <th>Country</th>
    <th>Age</th>
  </tr>
</thead>
  <tbody *ngFor="let item of results$ | async" >
     <tr   (click)="lgModal.show(item)">
      <td>
       {{item.firstName}}
      </td> 
      <td>{{item.lastName}}</td>
      <td>{{item.gender}}</td>
      <td>{{item.city}}</td>
      <td>{{item.country}}</td>
      <td>{{item.age}}</td>
    </tr>
  </tbody>
</table>

名字
姓
性别
城市
国家
年龄
{{item.firstName}
{{item.lastName}
{{item.gender}
{{item.city}
{{item.country}
{{item.age}
当我单击相应的行时,我只想传递相应的用户其他详细信息,但它将我的结果的完整json$传递给同一组件中的模式

  <div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" (click)="lgModal.hide()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">Complete Details</h4>
      </div>
      <div class="modal-body">
        <div  >
           {{ item | json }} // not getting item details here
        </div>
      </div>
    </div>
  </div>
</div>

&时代;
完整的细节
{{item | json}}//此处未获取项目详细信息

如何做到这一点???

如果我理解了您的问题,那么您忘记了从列表UI向您的模式传递相应的项目id。 e、 g.

然后在模态上显示点击的记录细节,我想你们不需要在模态上重复,因为它是单数记录


我希望这是正确的,对你有帮助

我就是这样想出来的

我又创建了一个函数,并通过该函数调用传递了所需的数据

在mycomponent.html中

<tr (click)="onClick(item,lgModal)">
    <div class="modal-body">

     <pre>{{ selecteditem | json }}  </pre>

       // Example 

         <h5>SChool Name:{{selecteditem?.schoolName}}</h5>

      </div>

在my组件中.ts

public selecteditem: Observable<Object>;

 onClick(item:any, lgModal:any){

   this.selecteditem = item;

   lgModal.show()

  //  console.log(this.selecteditem); // print in console

 }
public selecteditem:可见;
onClick(项:任意,lgModal:任意){
this.selecteditem=项目;
lgModal.show()
//console.log(this.selecteditem);//在控制台中打印
}
模态体(在component.html中)


{{selecteditem | json}}
//范例
学校名称:{{selecteditem?.schoolName}

我已将项传递给此函数(单击)=“lgModal.show(项)”,但它不起作用。我尝试了itI,但看不到任何访问项的方法。检查该数据的引用名称并使用绑定显示相应的数据,不要重复。@user32传递了对的引用,仍然没有output@VinodPharande当我单击一行时,相应的数据没有传递到模式。当您再次重复数据时,仅将该数据实例传递到您的模式(结果$)在modal@user32上,我可以编写自定义函数以便将数据传递给modalcan u告诉我一件事吗?模态html在同一个组件中或在另一个组件中。如果是这种情况,您必须进行组件通信。(@Input/Output)。@user32是的,两者都在同一个组件中,谢谢。我找到了解决方案。