fxmontigny / ng2-ace-editor

Ace editor integration with typescript for angular 4 - 5
MIT License
199 stars 92 forks source link

unable to use use ng2-ace-editor as FormControl #132

Open manuchadha1979 opened 4 years ago

manuchadha1979 commented 4 years ago

Hi

Does ng2-ace-editor support Form binding? I suppose so as I saw that it implements ControlValueAccessor.

I am on Angular6. I am trying to use ace-editor as a FormControl. I have added the following code in the template.

        <div ace-editor
          [(text)]="text"
          [mode]="'sql'"
          [theme]="'eclipse'"
          [options]="options"
          [readOnly]="false"
          [autoUpdateContent]="true"
          [durationBeforeCallback]="1000"
          (textChanged)="onChange($event)"
          style="min-height: 200px; width:100%; overflow: auto;"
          class="form-control" formControlName="answer" [ngClass]="validateField('answer')">
        </div>

But when I run the I see error

ERROR Error: No value accessor for form control with name: 'answer'

What I might be doing wrong?

manuchadha1979 commented 4 years ago

I think I was using it incorrectly. I was following the Directive instructions while I should have followed the Component instructions. I might be Ok. I'll test and confirm