我在这里缺少什么? md-input
是否应该单独加载到 module
文件中?
这有效:
<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 { }
最佳答案
那是因为在你的第二个示例中语法是错误的。在最新的 2.0.0 beta .1(我想您正在使用)中,md-input
关键字已替换为 mdInput
。因此,如果您想要使用 Angular Material 2 设计输入样式,只需输入
<md-input-container>
<input mdInput placeholder="Username" name="username">
</md-input-container>
关于 Angular Material 2 : 'md-input' is not a known element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42673201/