ngFor에서 ID를 전달하고 ID를 사용하여 드롭 다운을 채울 수있는 메소드를 호출 할 수 있습니까?각도 2는 ngFor 내에서 메소드 호출
그래서 내가 이달의 드롭 다운에 대한 모든 값을 얻을 수 dropwdownid 통과해야
<div class="container" style="width:100%; border:1px double">
<div class="row left" *ngFor='let controls of tabControls'>
<div class="col-md-3 text-left" style="border:1px dotted">
{{controls.DropDownTitle}}
</div>
<div class="col-md-9 text-left">
<select [(ngModel)]="populateValues(controls.DrodownID)">
//I will do this after populateValues which wil return an array of items
<option *ngFor="let item of items" [value]="item.id">
{{ item.name }}
</option>
</select>
</div>
</div>
</div>
출력 (내가 ngModel 갈 방법이 아니다 알아,하지만 난 그냥 예를 보여주고 싶었다).
'[(ngModel)] = "populateValues (controls.DrodownID)"는 유효하지 않습니다. 메소드에 양방향 바인딩을 사용할 수 없습니다. 또한 컨트롤에 바인딩하는 것도 의미가 없습니다. 작동하지 않는 템플릿 기반 및 반응 형 양식의 이상한 혼합입니다. https://angular.io/docs/ts/latest/guide/forms.html, https://angular.io/docs/ts/latest/cookbook/dynamic-form.html –
동적 양식이 아닙니다. 예를 들어 레이블이있는 드롭 다운의 동적 번호를 가져 오는 것입니다. Month : Drodown. 그런 다음 드롭 다운 ID를 메서드에 전달하여 드롭 다운 값을 반환합니다. – rgoal
@rgoal 방금 게시 한 답변을 살펴보십시오. http://stackoverflow.com/a/41987524/6294072 – Alex