मैं उपयोग कर रहा हूँ कोणीय 4 और कोणीय सामग्री 2. निम्न कोड के लिए नहीं है:खाका पार्स त्रुटियाँ: 'MD-फार्म क्षेत्र' एक ज्ञात तत्व
<form>
<md-form-field>
<input mdInput [ngModel]="userName" placeholder="User" [formControl]="usernameFormControl">
<md-error *ngIf="usernameFormControl.hasError('required')">
This is <strong>required</strong>
</md-error>
<input mdInput [ngModel]="password" placeholder="Password" [formControl]="passwordFormControl">
<md-error *ngIf="passwordFormControl.hasError('required')">
This is <strong>required</strong>
</md-error>
<button md-raised-button color="primary" [disabled]="!usernameFormControl.valid || !passwordFormControl.valid">Login</button>
</md-form-field>
</form>
मैं एक त्रुटि हो रही है:
Template parse errors: 'md-form-field' is not a known element: 1. If 'md-form-field' is an Angular component, then verify that it is part of this module. 2. If 'md-form-field' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->]
क्या आप कृपया मेरी मदद कर सकते हैं जहां मुझे याद आ रही है?
के बाद मेरी app.module.ts
कोड जहाँ मैं सामग्री मॉड्यूल आयात किया है है:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { LoginComponent } from './login.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
MdAutocompleteModule,
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
MdCheckboxModule,
MdChipsModule,
MdCoreModule,
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdNativeDateModule,
MdPaginatorModule,
MdProgressBarModule,
MdProgressSpinnerModule,
MdRadioModule,
MdRippleModule,
MdSelectModule,
MdSidenavModule,
MdSliderModule,
MdSlideToggleModule,
MdSnackBarModule,
MdSortModule,
MdTableModule,
MdTabsModule,
MdToolbarModule,
MdTooltipModule
} from '@angular/material';
import {CdkTableModule} from '@angular/cdk';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
MdAutocompleteModule,
MdButtonModule,
MdButtonToggleModule,
MdCardModule,
MdCheckboxModule,
MdChipsModule,
MdCoreModule,
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdNativeDateModule,
MdPaginatorModule,
MdProgressBarModule,
MdProgressSpinnerModule,
MdRadioModule,
MdRippleModule,
MdSelectModule,
MdSidenavModule,
MdSliderModule,
MdSlideToggleModule,
MdSnackBarModule,
MdSortModule,
MdTableModule,
MdTabsModule,
MdToolbarModule,
MdTooltipModule,
CdkTableModule
],
declarations: [
AppComponent,
LoginComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
ओपी के मामले के लिए एक विकल्प के रूप में app.module.ts
app.module.ts में नीचेimport { FormsModule } from '@angular/forms'
, आयात 'MdInputModule' भी काम करेगा, कि मॉड्यूल फिर से के रूप में -पोर्ट्स 'MdFormFieldModule' –
मेरे पास भौतिक संस्करण 2.0.0-बीटा 3 है, और MdFormFieldModule मेरे लिए पहचाना नहीं गया है। तुम जानते हो क्यों? MdInputModule ठीक से मान्यता प्राप्त है। धन्यवाद! – Batsheva
@ बत्शेवा क्योंकि '2.0.0-beta.10' में 'MdFormFieldModule' पेश किया गया था जैसा कि मैंने उत्तर में बताया है। – Faisal