Angular 在html中动态命名div,并使用@ViewChild(';xyz';)div:ElementRef;棱角分明

Angular 在html中动态命名div,并使用@ViewChild(';xyz';)div:ElementRef;棱角分明,angular,Angular,我想在*ngfor中创建一个div,并为其分配一个动态id,然后使用viewchild和elementRef在组件中访问它。我当前的html如下所示 <ng-container *ngFor="let consult of crap | keyvalue; let j = index; trackBy: trackByFn;"> <td> <input type="radio" name="

我想在*ngfor中创建一个div,并为其分配一个动态id,然后使用viewchild和elementRef在组件中访问它。我当前的html如下所示

<ng-container *ngFor="let consult of crap | keyvalue; let j = index; trackBy: trackByFn;">
     <td>
       <input  type="radio" name="radio-{{i}}" id="radio-{{i}}-{{j}}(click)="questBuild(consult)"/>
             <label class="sr-text" for="radio-{{i}}-{{j}}">{{consult.value.text}}</label>
               <ng-container *ngIf="consult.value.quest">
                  <div #questions></div>
                </ng-container>
          </td>
    </ng-container>
f 那么,有没有一种方法可以在*ngFor中动态命名#问题,并在component中使用@viewchild访问它呢。View Children是一个查询列表,其中包含所有元素

@ViewChildren('question') questions:QueryList<ElementRef> 
//or is yer "questions" are components
@ViewChildren('question') questions:QueryList<ComponentName> 
@ViewChildren('question') questions:QueryList<ElementRef> 
//or is yer "questions" are components
@ViewChildren('question') questions:QueryList<ComponentName> 
const question=this.questions.find((x,i)=>i==index)