网格标签在 angular 2 中不起作用

grid tags not working in angular 2

我正在尝试使用 angular material2 在基于 Angular 2 的应用程序中创建网格布局,但是当我尝试在 "app.component.html" 文件中创建结构时,网格标签收到 未知 html 标签 的错误。这是我如何尝试执行此操作的代码: app.component.html

<div class="col-md-8">
        <div class="game-area">
            <md-grid-list class="tick-tack-grid" cols="3">
                <md-grid-tile *ngFor="let block of gs.blocks; let i = index; trackBy: trackByFn" (click)="playerClick(i)"><i [class]="block.symbol == 'done' ? 'material-icons tick' : 'material-icons cross'">{{ block.symbol }}</i></md-grid-tile>
            </md-grid-list>
        </div>
    </div>

app.component.ts

import { Component } from '@angular/core';
import { Player } from './Player';
import { Box } from './Box';
import { GameService } from './game.service';
...

我相信您没有在应用程序模块中导入 MdGridListModule 模块。您需要这样做:

import {
  MdGridListModule
} from '@angular/material';

@NgModule({

  imports: [
    MdGridListModule
  ]
})
export class AppModule {}

参见说明这一点的 plunk (main.ts)。