我正在尝试使用 angular-schema-form在一个 Angular 项目上,但我无法将其导入到我的 app.module.ts 上。这是我的配置:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { schemaForm } from 'angular-schema-form';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
schemaForm
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
但是,当我尝试运行 ngserve
时,它正确遵守,但浏览器显示一条错误,指出 schemaForm 未定义: Uncaught Error: Unexpected value 'undefined' returned by the模块“AppModule”
我已使用 npm-install 正确安装了依赖项,但无法生成单个表单。阅读官方文档它说:
load the schemaForm module in your module definition
它显示了如何使用以下方式导入它的示例:angular.module('myModule', ['schemaForm'])
。问题是我没有使用 angular.module 启动模块,而是使用上面代码中显示的 @NgModule 引导方法。该项目是使用 Angular CLI 命令 ng new project
有人可以指导我如何导入和使用 angular-schema-form 的正确方向吗? ?谢谢。
最佳答案
这个包是 angularjs 包。它不是为 Angular 而构建的。请找到操作系统为 Angular 构建的架构形式的其他一些包。检查this link for your reference
关于javascript - 在 app.module 上导入 schema-form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45041020/