模板解析错误:' md-grid-tile'不是一个已知的元素

时间:2017-08-04 19:13:36

标签: angular angular-material2

我在新的Angular 2中使用Material Design。我将它连接到app.module,如:

VM1967 vendor.bundle.js:63286 Uncaught Error: Template parse errors:
'md-grid-tile' is not a known element:
1. If 'md-grid-tile' is an Angular component, then verify that it is part of this module.
2. If 'md-grid-tile' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
    <md-grid-list cols="7" rowHeight="2" id="weekly_schedule">

加载页面后,我在控制台中收到错误:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';

import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module';
import { HomeRoutingModule } from './home-routing.module';
import { HomeComponent } from './home.component';
import { QuoteService } from './quote.service';

import { BrowserModule } from '@angular/platform-browser';
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MdGridListModule, MdCardModule} from '@angular/material';

@NgModule({
  imports: [
    BrowserAnimationsModule,
    BrowserModule,
    CommonModule,
    TranslateModule,
    CoreModule,
    SharedModule,
    HomeRoutingModule,
    MdGridListModule
  ],
  declarations: [
    HomeComponent
  ],
  providers: [
    QuoteService
  ]
})
export class HomeModule { }

如何解决?我尝试过任何方式。

完整文件是连接材料(现在它不会给出任何错误,但页面在浏览器中加载不受限制)

shared

2 个答案:

答案 0 :(得分:3)

changelog中看到的2.0.beta-11中删除了MaterialModule, 所以你必须使用 mat 而不是 md 。但仍然在进行更改,因此您需要跟踪git hub

答案 1 :(得分:0)

MGridListModule 替换为 MatGridListModule ,也可以从导入{MatGridListModule}导入&#39; @ angular / material&#39;;

你会很高兴...