0
要素のリストを選択して、その値の1つにオプションの値を指定してフォーカスを合わせたいとします。* ngForループを取得できませんでした<md-option> @ViewChildrenを使用している要素
select.component.template:
<md-select
[formControl]="selectFormControl"
(click)="detectKeys()"
[required]="isRequired"
[disabled]="isDisabled"
[attr.role]="'listbox'"
[attr.aria-labelledby]="placeholder"
placeholder="placeholder">
<md-option #selectBox *ngFor="let option of options" [value]="option.value">
{{option.description}}
</md-option>
</md-select>
select.component.ts:
export class UiSelectComponent implements OnInit, AfterViewInit {
....
@Input() options: Object[];
@ViewChildren('selectBox') selects: QueryList<any>;
....
}
ngAfterViewInit() {
console.log(this.selects.length); // comes up empty results
}
の 'はそうですか? –
kyw
QueryList
上のサブスクリプションを置くことを考えることができます。ありがとうございました。最後の質問: 'QueryList'のタイプ'@kywここにはい、 'component'については、' Type'コンポーネント –