首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >角度材质:选择列表示例不起作用

角度材质:选择列表示例不起作用
EN

Stack Overflow用户
提问于 2018-12-20 03:23:43
回答 1查看 3.3K关注 0票数 2

我正在尝试使用角度材质(7.0)选择列表as described here

页面上的示例代码片段是

代码语言:javascript
复制
  <mat-selection-list #shoes>
    <mat-list-option *ngFor="let shoe of typesOfShoes">
      {{shoe}}
    </mat-list-option>
  </mat-selection-list>

  <p>
    Options selected: {{shoes.selectedOptions.selected.length}}
  </p>

使用TS文件中定义的typesOfShoes,如其代码片段中所述:

代码语言:javascript
复制
export class HomeComponent implements OnInit {
  typesOfShoes: string[] = ['Boots', 'Clogs', 'Loafers', 'Moccasins', 'Sneakers'];
  constructor() {}
  ngOnInit() {}
}

对我来说是有意义的,但是当我尝试编译时,我得到了错误

代码语言:javascript
复制
ERROR in: Can't bind to 'ngForOf' since it isn't a known property of 'mat-list-option'.
1. If 'mat-list-option' is an Angular component and it has 'ngForOf' input,
 then verify that it is part of this module.
2. If 'mat-list-option' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA'
 to the '@NgModule.schemas' of this component to suppress this message.
etc.

我已经将MatListModule导入到我的应用程序模块中。

我看不到与要导入的列表选项相关的其他模块。

这里我漏掉了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-20 03:34:10

@NgModule()中导入BrowserModule (如果是子模块,则导入CommonModule

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';

@NgModule({
  imports: [BrowserModule],
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53857926

复制
相关文章

相似问题

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