2017-04-06 1 views
0

formbuilder를 사용하여 물리적 페이지에 'product.name'을 어떻게 나열 할 수 있습니까? 그것은 입력 필드에 대한 잘 작동하지만, 내가 처음 TD의 실제 단어를 쓰고 싶어 : 여기형식 빌더를 사용하여 입력 필드에 product.name을 쓸 수 있습니다.

<table class="editPackagesGeneralTable" formArrayName="products"> 
    <tr><th class="first">Product/Gift</th><th>Description</th><th>Cost</th><th class="last">Quantity</th></tr> 
    <tbody> 
    <tr *ngFor="let product of myForm.controls.products.controls; let i=index" [formGroupName]="i"><td>{{product.name}}</td><td>{{product.description}}</td><td>{{product.unitCost}}</td><td><input type="hidden" formControlName="id" /><input type="text" formControlName="name" /></td></tr> 
    </tbody> 
</table> 

것은 내 타이프 라이터입니다 :

this.myForm = this.fBuilder.group({ 
      products: this.fBuilder.array([]) 
     }); 

     this.httpService.getExtrasList() 
      .subscribe((res) => { 
       this.items = res.json(); 
       console.log(res.json()); 

       this.items.forEach(element => { 
        (<FormArray>this.myForm.get('products')).push(this.fBuilder.group({ 
         id: [element.id], 
         name: [element.name] 
        })); 
       }); 

      }); 

답변

2

product.name가 FormGroup 예, 나는 {{product.controls.name.value}}를 추측 작동해야합니다.

+0

타이프 스크립트를 포함하도록 제 질문을 수정했습니다. 어떻게 수정하고 템플릿에서 무엇인가를 변경해야합니까? –

+0

오, 미안해. 이 대답은 부적절합니다. '{{product.name.value}}'가 작동해야합니다. 그거야? – n00dl3

+0

Aw 나는 그것을 시도했다. 그러나 "정의되지 않은 속성 값 '을 읽을 수 없다는 오류가 발생했습니다. 지금까지 많은 도움을 주셔서 감사합니다 :) –