how to use angular-editor with mat-form-field ? faccing issue with mat-form-field must contain a MatFormFieldControl
code :
<mat-form-field <angular-editor matInput matTextareaAutosize formControlName="description" [config]="editorConfig"> <mat-error *ngIf="courseAssignmentManagementForm.get('description').hasError('required')" Please enter the assignment's description mat-form-field>
I use angular-editor as separate component in this case:
<mat-form-field class="full-width-input">
<input matInput placeholder="Заголовок (без точки в конце)" formControlName="title" (blur)="updatePath()">
<mat-error *ngIf="isFieldInvalid('title')">
Введите заголовок статьи (без точки в конце)
</mat-error>
</mat-form-field>
<div class="editor">
<angular-editor id="e1" #angularEditor (blur)="onBlur()" formControlName="body" [config]="editorConfig"></angular-editor>
</div>
<mat-form-field class="full-width-input">
<textarea class="textarea" matInput placeholder="Введение в статью (без точки в конце)" formControlName="introduction"></textarea>
<mat-error *ngIf="isFieldInvalid('introduction')">
Введите введение в статью (без точки в конце)
</mat-error>
</mat-form-field>
Thank you Kolkov, I am trying with your solution
do I need to implement ControlValueAccessor and MatFormFieldControl.
worked for me <angular-editor
formControlName="description" >
</angular-editor>
I use
angular-editoras separate component in this case:<mat-form-field class="full-width-input"> <input matInput placeholder="Заголовок (без точки в конце)" formControlName="title" (blur)="updatePath()"> <mat-error *ngIf="isFieldInvalid('title')"> Введите заголовок статьи (без точки в конце) </mat-error> </mat-form-field> <div class="editor"> <angular-editor id="e1" #angularEditor (blur)="onBlur()" formControlName="body" [config]="editorConfig"></angular-editor> </div> <mat-form-field class="full-width-input"> <textarea class="textarea" matInput placeholder="Введение в статью (без точки в конце)" formControlName="introduction"></textarea> <mat-error *ngIf="isFieldInvalid('introduction')"> Введите введение в статью (без точки в конце) </mat-error> </mat-form-field>
thank you its worked for me , is there any option to set min-length or max-length limit
Look at the config please https://github.com/kolkov/angular-editor/blob/master/projects/angular-editor/src/lib/config.ts#L17
Thank you very much for your quick response and support. Yes, I follow this config file but where do I change the min length define and I want to remove the image tab from the toolbar .
Hello @kolkov
I want to remove the image and code tab from my toolbar how do I remove it from my toolbar.
not working for me :
:host /deep/ angular-editor#myEditor .angular-editor-button[title="Insert Image"]{
display: none !important;
}
Hello @kolkov I want to remove the image and code tab from my toolbar how do I remove it from my toolbar. not working for me :
:host /deep/ angular-editor#myEditor .angular-editor-button[title="Insert Image"]{ display: none !important; }worked for me.angular-editor-toolbar-set .angular-editor-button[title="Insert Image"]:nth-last-child(2) { display: none !important; } .angular-editor-toolbar-set .angular-editor-button[title="HTML Code"]:nth-last-child(1) { display: none !important; }
https://github.com/kolkov/angular-editor/issues/11 this may help... then we need ability to customize toolbar by config.
Reopen please if problem persists.
Hi @kolkov , Is there anyway to get formControlName="description" from angular-editor. Below control value doesn't get if i use HTML code functionality. Client side mat-error shows.
It would be great if you suggested. Thank you. <angular-editor [config]="config" formControlName="description">
config: AngularEditorConfig = { editable: true, spellcheck: true, height: '15rem', minHeight: '5rem', placeholder: 'Enter embed code here...', translate: 'no', defaultParagraphSeparator: 'p', defaultFontName: 'Arial', toolbarHiddenButtons: [ ['bold'] ], customClasses: [ { name: "quote", class: "quote", }, { name: 'redText', class: 'redText' }, { name: "titleText", class: "titleText", tag: "h1", }, ] };
contentFormInit() { this.contentForm = this.fb.group({ name: ['', Validators.required], description: ['', Validators.required], content: [''], status: ['Active', Validators.required], skippable: [false], contentPosition: [Validators.required] });
}