Disable edit mode in Angular Inplace editor component

27 Apr 20242 minutes to read

The edit mode of In-place Editor can be disabled by setting the disabled property value to true. In the following sample, when check or uncheck the checkbox, In-place Editor component will disable or enable the edit mode.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { InPlaceEditorAllModule } from '@syncfusion/ej2-angular-inplace-editor'
import { CheckBoxModule, ButtonModule } from '@syncfusion/ej2-angular-buttons'



import { Component, ViewChild } from '@angular/core';
import { InPlaceEditorComponent } from '@syncfusion/ej2-angular-inplace-editor';
import {  ChangeEventArgs } from '@syncfusion/ej2-buttons';

@Component({
imports: [
         InPlaceEditorAllModule, CheckBoxModule, ButtonModule
    ],


standalone: true,
    selector: 'app-root',
    template: `
    <div id='container'>
    <table class="table-section">
        <tr>
            <td> Disabled: </td>
            <td>
                <ejs-checkbox id="enable" label="Disable" [checked]="false" (change)="onChange($event)"></ejs-checkbox>
            </td>
        </tr>
        <tr>
            <td class="sample-td"> Enter your name: </td>
            <td class="sample-td">
                <ejs-inplaceeditor #element id="element" mode="Inline" value="Andrew" [model]="model"></ejs-inplaceeditor>
            </td>
        </tr>
       </table>
    </div>
    `
})

export class AppComponent {
    @ViewChild('element') editObj?: InPlaceEditorComponent;
    public model: object = { placeholder: 'Enter some text' };
    public onChange(e: ChangeEventArgs): void {
        (this.editObj as InPlaceEditorComponent).disabled = e.checked as boolean;
        this.editObj?.dataBind();
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));