如何基于从angular4列表中选择的数字打开表格的数量?

时间:2019-01-24 16:48:10

标签: angular4-httpclient

当从list3中选择数字并单击“提交”按钮时如何制作与我在angular4中从list3中选择的数字相同的乘客详细信息表格? 我试图在变量中获取选定的数字并传递给子组件并在子组件中为其循环但无法正常工作 我的代码是 例如父组件

export class FlightDetailsComponent implements OnInit {

  public num_of_passengers:number;

num_passengers_DropDownChanged(value: any) {
  this.num_of_passengers=value;
} 

for child componnet 

export class PassengerDtailComponent implements OnInit,OnChanges {

  @Input() num_of_passengers:number;

  public allPassengerChangeLogs: number[];

 ngOnChanges(changes: SimpleChanges) {

    this.allPassengerChangeLogs = new Array(changes.num_of_passengers.currentValue).fill(1);
  }


and my template for child component is
<div class=container  *ngFor="let in of allPassengerChangeLogs ; let i= index" >

    <form>
      <div class="form-group" style="display: inline">

        <input type="text" class="form-control" id="lbl_txt" placeholder="First name">
        <input type="text" class="form-control" id="input_txt" [(ngModel)] ="F_name"/>

        <input type="text" class="form-control" id="lbl_txt" placeholder="Last name">
        <input type="text" class="form-control" id="input_txt" [(ngModel)] ="L_name"/>
      </div>

this photo of my question

0 个答案:

没有答案