在运行时,我从JSON对象获取所有记录,并在表单控件中获取值.但是,在表单数组中,我只获得了许多记录中的第一个.
控制台中显示的错误:
在FormArray._throwIfControlMissing中找不到索引1处的表单控件
JSON对象和错误的图像:
export interface IService {
ServiceID: number,
Name: string,
Staffs: IStaffView[]
}
export interface IStaffView {
StaffServiceID: number,
StaffID: number,
Name: string
}Run Code Online (Sandbox Code Playgroud)
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Observable } from 'rxjs/Rx';
import { FormBuilder, FormGroup, FormControl, FormArray , Validators } from '@angular/forms';
import { RESTService } from '../../Service/REST.service';
import { IService, IStaffView } from '../../Model/service.model';
import { …Run Code Online (Sandbox Code Playgroud)