Html 角料台:can';t绑定到';matRowDefColumn';
我试图使用一个有角度的材料表。我导入了模块,但出现了模板解析错误。 HTML: 数据源:我使用Html 角料台:can';t绑定到';matRowDefColumn';,html,angular,typescript,angular-material,Html,Angular,Typescript,Angular Material,我试图使用一个有角度的材料表。我导入了模块,但出现了模板解析错误。 HTML: 数据源:我使用returnDeadProjectList() 我得到的错误是: compiler.js:466 Uncaught Error: Template parse errors: Can't bind to 'matRowDefColumn' since it isn't a known property of 'mat-row'. 1. If 'mat-row' is an Angular compone
returnDeadProjectList()
我得到的错误是:
compiler.js:466 Uncaught Error: Template parse errors:
Can't bind to 'matRowDefColumn' since it isn't a known property of 'mat-row'.
1. If 'mat-row' is an Angular component and it has 'matRowDefColumn' input, then verify that it is part of this module.
2. If 'mat-row' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
如果我在schemas:[]中写入CUSTOM\u ELEMENTS\u SCHEMA
,
我会得到一个不同的错误:
compiler.js:466 Uncaught Error: Template parse errors:
Property binding matRowDefColumn not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("` `<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
[ERROR ->]<mat-row *matRowDef="let row; column: displayedColumns;"></mat-row>
compiler.js:466未捕获错误:模板分析错误:
嵌入模板上的任何指令均未使用属性绑定matRowDefColumn。确保属性名称拼写正确,并且所有指令都列在“@NgModule.declarations”中。("` `
[错误->]
有人知道我缺少什么吗?我应该有我需要的所有导入,但不知怎么的,它找不到元素。此外,我甚至不使用
matHeaderRowDef
将此代码添加到你的.component.ts和app.module.shared.ts中
它对我有用
import {
MatPaginator, MatSort, MatTable, MatTableModule, MatTabHeader,
MatHeaderRow, MatHeaderCell, MatHeaderCellDef, MatHeaderRowDef,
MatSortHeader, MatRow, MatRowDef, MatCell, MatCellDef,
_MatCell, _MatCellDef, _MatHeaderCellDef, _MatHeaderRowDef
} from '@angular/material';
@NgModule({
imports: [MatPaginator, MatSort, TableDataSource,
CdkTableModule, MatTable, MatTableModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
declarations: [
MatTabHeader,
MatHeaderRow,
MatHeaderCell,
MatHeaderCellDef,
MatHeaderRowDef,
MatSortHeader,
MatRow,
MatRowDef,
MatCell,
MatCellDef,
_MatCell,
_MatCellDef,
_MatHeaderCellDef,
_MatHeaderRowDef
]
})
代码片段
属性名称有问题。MatRowDef有属性列而不是列。
换成
之后它应该可以工作。您能创建plunkr模板吗?
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from "@angular/common";
import 'hammerjs';
import { ProjectService } from './services/project.service';
import { UserService } from './services/user.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { MatInputModule, MatButtonModule, MatExpansionModule, MatDatepickerModule, MatNativeDateModule, MatToolbarModule, MatListModule, MatIconModule, MatProgressSpinnerModule, MatSlideToggleModule, MatTableModule, MatPaginatorModule } from '@angular/material';
import { AppComponent } from './app.component';
import { MyFormComponent } from './my-form/my-form.component';
import { BitbucketComponent } from './bitbucket/bitbucket.component';
import { UserComponent } from './user/user.component';
import { ProjectComponent } from './project/project.component';
import { CdkTableModule } from '@angular/cdk/table';
compiler.js:466 Uncaught Error: Template parse errors:
Can't bind to 'matRowDefColumn' since it isn't a known property of 'mat-row'.
1. If 'mat-row' is an Angular component and it has 'matRowDefColumn' input, then verify that it is part of this module.
2. If 'mat-row' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
compiler.js:466 Uncaught Error: Template parse errors:
Property binding matRowDefColumn not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("` `<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
[ERROR ->]<mat-row *matRowDef="let row; column: displayedColumns;"></mat-row>
import {
MatPaginator, MatSort, MatTable, MatTableModule, MatTabHeader,
MatHeaderRow, MatHeaderCell, MatHeaderCellDef, MatHeaderRowDef,
MatSortHeader, MatRow, MatRowDef, MatCell, MatCellDef,
_MatCell, _MatCellDef, _MatHeaderCellDef, _MatHeaderRowDef
} from '@angular/material';
@NgModule({
imports: [MatPaginator, MatSort, TableDataSource,
CdkTableModule, MatTable, MatTableModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
declarations: [
MatTabHeader,
MatHeaderRow,
MatHeaderCell,
MatHeaderCellDef,
MatHeaderRowDef,
MatSortHeader,
MatRow,
MatRowDef,
MatCell,
MatCellDef,
_MatCell,
_MatCellDef,
_MatHeaderCellDef,
_MatHeaderRowDef
]
})