[Fixed] Im having trouble with inserting dynamically created material input string to web page in angular


Below is the code, where im generating a Textarea material input along with a value and inserting it into a div called child_2. the problem is its loading default HTML Textarea and also without value loaded inside it.

      const box = document.getElementById(cmt_id);

        const child_1 = box.children[0];
        const child_2 = box.children[1];
        let comment_text = child_1.innerHTML;

        let inputText = `
          <mat-form-field appearance="outline" class="w-100">
          (keyup.enter)="updateComment($event.target.value, ct.id)"
          child_2.innerHTML = inputText;

this code works as in the picture.

generated Textarea input.
please help!


@ViewChildren("textField") textFields: QueryList;

try to understand this concept in angular…

Leave a Reply

(*) Required, Your email will not be published