我想让模块在那里我声明和更新所有 ngx-formly 的东西,以将此模块作为全局模块导入另一个模块。但是我在组件中有错误,这些组件是 ngx-formly 组件。
formly.module.ts
import { FormlyPassword } from './../shared/formly-custom-templates/formly-password.type';
import { NgModule } from '@angular/core';
import { FormlyNgZorroAntdModule } from '@ngx-formly/ng-zorro-antd';
@NgModule({
declarations: [FormlyPassword],
imports: [
FormlyModule,
FormlyNgZorroAntdModule,
FormlyModule.forChild({
types: [
{ name: 'custom-input', component: FormlyPassword },
]
}),
],
})
export class NgFormlyModule { }
核心模块.ts
import { NgFormlyModule } from './../formly/formly.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LoginComponent } from './components/login/login.component';
import { ForgetPasswordComponent } from './components/forget-password/forget-password.component';
import {CoreRoutingModule} from './core-routing.module';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {ZorroModule} from '../zorro/zorro.module';
import {SharedModule} from '../shared/shared.module';
@NgModule({
declarations: [LoginComponent, ForgetPasswordComponent],
imports: [
CommonModule,
CoreRoutingModule,
SharedModule,
FormsModule,
ReactiveFormsModule,
ZorroModule,
NgFormlyModule // here is imported custom module
]
})
export class CoreModule { }
错误
ERROR in src/app/core/components/login/login.component.html:44:9 - error NG8001: 'formly-form' is not a known element:
1. If 'formly-form' is an Angular component, then verify that it is part of this module.
2. If 'formly-form' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
44 <formly-form [model]="model" [fields]="fields">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/core/components/login/login.component.ts:7:18
7 templateUrl: './login.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component LoginComponent.