Integration in Angular Inplace editor component

27 Sep 20233 minutes to read

The In-place Editor supports adding HTML5 input components using the template property. The Template property can be given as either a string or a query selector.

As a string

The HTML element tag can be given as a string for the template property. Here, the input is rendered as an HTML template.

template: "<div><input type='text' id='name'></input></div>"

As a ng-template

You can render other components inside In-place editor using Angular ng-template. We need to use ng-template inside the <ejs-inplaceeditor> tag with #template attribute, which is mandatory to render that template.

<ng-template #template>
    <input id="date" value="2018-05-23" type="date">
</ng-template>

Template mode, the value property not handled by the In-place Editor component. So, before sending a value to the server, you need to modify at actionBegin event, otherwise, an empty string will pass. In the following template sample, before submitting a data to the server, event argument and value property content updated in the actionBegin event handler.

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

@Component({
    selector: 'app-root',
    template: `
    <div id='container'>
        <span class="content-title"> Select date: </span>
        <ejs-inplaceeditor #element id="element" mode="Inline" value="2018-05-23" (actionBegin)="actionBegin($event)">
            <ng-template #template>
                <input id="date" value="2018-05-23" type="date">
            </ng-template>
        </ejs-inplaceeditor>
    </div>
    `
})

export class AppComponent {
    @ViewChild('element') editObj?: InPlaceEditorComponent;
    public actionBegin(e: ActionBeginEventArgs): void {
        const value = (<any>(this.editObj as InPlaceEditorComponent).element.querySelector('#date')).value;
        (this.editObj as InPlaceEditorComponent).value = value;
        (<any>e).value = value;
    }
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { InPlaceEditorAllModule } from '@syncfusion/ej2-angular-inplace-editor';
import { AppComponent } from './app.component';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule, InPlaceEditorAllModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);