我在這裏錯過了什麼? md-input
是否應單獨加載到module
文件中?角度材料2:'md-input'不是已知元素
這工作:
<md-input-container>
<input mdInput name="username" placeholder="Username" [(ngModel)]="username" #name="ngModel" required>
</md-input-container>
然而,這種失敗:
<md-input placeholder="amount" align="end">
<span md-prefix>$ </span>
<span md-suffix>.00</span>
</md-input>
,出現以下錯誤:
Unhandled Promise rejection: Template parse errors:
'md-input' is not a known element:
1. If 'md-input' is an Angular component, then verify that it is part of this module.
2. If 'md-input' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
</div>
<div>
[ERROR ->]<md-input placeholder="amount" align="end">
<span md-prefix>$ </span>
app.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from "@angular/common";
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from "@angular/forms";
import { MaterialModule } from "@angular/material";
import { AppComponent } from './app.component';
import "hammerjs";
@NgModule({
imports: [
CommonModule,
BrowserModule,
FormsModule,
MaterialModule.forRoot()
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
試過了,同樣的錯誤:「未處理的承諾拒絕:模板解析錯誤: ‘MD-輸入’不是一個已知的元素:」 – kmansoor
對不起,我沒有把它包裝在一個MD輸入接收器中。檢查一下。 –