0

Due to my requirement, I have to use inner HTML with reactive forms but when I am trying to get this. form.value, I am just receiving empty values even though my control is assigned with value.

I have forked my repo in below link https://stackblitz.com/edit/angular-ivy-6ex96b?file=src%2Fapp%2Fsafehtml.pipe.ts

  • looks like it's not possible..: [Is it possible to include and emit an event in the string that is sanitized using DomSanitizer pipe in Angular?](https://stackoverflow.com/questions/50678508/is-it-possible-to-include-and-emit-an-event-in-the-string-that-is-sanitized-usin), and [ngModel, click not working in angular 4 in dynamically added html](https://stackoverflow.com/questions/50058319/ngmodel-click-not-working-in-angular-4-in-dynamically-added-html) – traynor Oct 24 '22 at 09:36
  • my requirement is such that I have to create an application like Microsoft forms, where the user defines JSON, based on JSON I have to render the form with validation dynamically. Can you please suggest me a better approach. – Ajay Ganesh04 Oct 24 '22 at 12:59
  • 1
    well, if its' JSON, then you might try creating [dynamic forms](https://angular.io/guide/dynamic-form). Try using `FormArray ` to create controls and validation from JSON, and then `ngFor` and `ngIf` to construct and render HTML based on that form/JSON structure, see here: [Dynamically add fields in Dynamic Form Array](https://stackoverflow.com/questions/70572108/dynamically-add-fields-in-dynamic-form-array) – traynor Oct 24 '22 at 16:32
  • Yeah got it will give it a shot – Ajay Ganesh04 Oct 25 '22 at 02:22
  • Thank you this issue is sorted by using dynamic forms approach in angular [link](https://angular.io/guide/dynamic-form) – Ajay Ganesh04 Dec 22 '22 at 10:34

0 Answers0