zijianhuang / webapiclientgen

Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
MIT License
167 stars 38 forks source link

POCO2TS.exe to generate typed FormGroup of Angular #123

Closed zijianhuang closed 6 months ago

zijianhuang commented 1 year ago

There might be TS/JS program already doing so upon interfaces?

zijianhuang commented 8 months ago

https://angular.io/guide/typed-forms https://angular.io/guide/form-validation

zijianhuang commented 8 months ago

Typed form group declaration. Helper classes to create form group object.

zijianhuang commented 8 months ago

properties of array and complex type may be skipped, for the sake of relational db.

zijianhuang commented 8 months ago

The design of FormGroup depends on many factors:

  1. Whether the backend storage is relational db or structural data.
  2. UX
  3. business workflows.
  4. Predefined values.
zijianhuang commented 8 months ago

https://github.com/angular/angular/issues/46864

zijianhuang commented 8 months ago

If you are using Reactive Forms, you may have been dreaming of generating a FormGroup from an interface/model rather than hand-crafting. I have created an proposal to the Angular team through https://github.com/angular/angular/issues/52559

If you like this, please upvote to make it happen sooner. And I have created a code generator that can read .NET data models and generate interfaces along with functions of creating typed FormGroup which can be used in your Angular app with Reactive Forms: https://www.nuget.org/packages/Fonlow.WebApiClientGenCore.NG2FormGroup

And the generated codes of a real world project is here: https://github.com/zijianhuang/DemoCoreWeb/blob/master/RealWorldExamples/PoetryManagementAndPublishing/WebApiNG2ClientAuto.ts

zijianhuang commented 6 months ago

feature done. new issue if the ng team could improve the supports for automating Reactive Forms.