简体   繁体   中英

Dynamically create forms from JSON Schema [Angular 8]

I'm struggling with creating dynamically forms from JSON Schema in Angular 8. I found some libraries for that, but one is very old (last commit ~2 yr ago) and fork of it from this year.

I don't want to use first one, because it's deprecated with angular 8, so my choise was the second one. I have trouble because this project isn't on any npm repositories, only on github. I downloaded it form git like this:

npm i rhalff/angular2-json-schema-form#angular-8

When I started to build my project with this dependency and after attach the import into app.module.ts the result is like this:

ERROR in src/app/app.module.ts:20:65 - error TS2307: Cannot find module 'angular2-json-schema-form'.

I found that in node_module there isn't any src or dist folder and then I looked into github projecet and I found that in /.npmignore there is a src.

I have a some solution about that, but it's not the final one and I think is really bad idea. I will locally clone git repository, next then build it with npm run build and then npm link and then npm link <someName> in project catalog.

Can anyone know is there any solution of this problem or maybe someone can suggest me any other libraries for converting JSON Schema for Angular 8 forms?

您可以考虑使用支持json-schema Formly ,它提供了一堆示例以开始使用https://formly.dev/examples/advanced/json-schema

You can use dynamic-form-schema . It is completely schema based and provide options to add validations, conditional validations and drop down conditional option in the schema. For more details, check link: Rapid Angular Reactive Form Component Development Based on a Schema

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM