首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ng-模板、mat-selection-list和ngFor

ng-模板、mat-selection-list和ngFor
EN

Stack Overflow用户
提问于 2018-10-17 05:44:33
回答 1查看 856关注 0票数 0

我通过遵循this文章构建了一个工具提示指令,

我正在尝试将templateRef传递给tooltip指令。

下面是我的共享组件,

在ts,

代码语言:javascript
复制
@Input() fieldPreferences: IFieldPreference[];

在html,

代码语言:javascript
复制
<mat-selection-list #list>
  <mat-list-option  
    *ngFor="let preference of fieldPreferences"
    [selected]="preference.selected"
    (click)="showPreferenceChanged(list)"
    [value]="preference.field">
    {{preference.field}}
  </mat-list-option>
</mat-selection-list>

在家长,

代码语言:javascript
复制
<mat-icon tooltip [content]="template">settings</mat-icon>

<ng-template #template>
 <field-preferences
    [fieldPreferences]="fieldPreferences"
    (selectedFields)="showPreferenceChanged($event)">
 </field-preferences>
</ng-template>

工具提示未显示任何内容(即未生成mat-list-option )。根据这个SO OP,问题出在*ngForng-template上。

我试着改成,

代码语言:javascript
复制
<mat-selection-list #list>
  <mat-list-option  ngFor let-preference [ngForOf]="fieldPreferences"
      [selected]="preference.selected"
      (click)="showPreferenceChanged(list)"
      [value]="preference.field">
      {{preference.field}}
    </mat-list-option>
  </mat-selection-list>

尽管如此,工具提示仍呈现为无内容。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52844440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档