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
.
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>"
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.element.querySelector('#date')).value;
this.editObj.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';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 InPlace Editor Sample</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript InPlace Editor Controls" />
<meta name="author" content="Syncfusion" />
<link href="//cdn.syncfusion.com/ej2/20.1.58/material.css" rel="stylesheet" />
<link href="index.css" rel="stylesheet" />
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.9.0/zone.min.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<app-root>
<div id='loader'>LOADING....</div>
</app-root>
</body>
</html>
#container {
display: flex;
justify-content: center;
}
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
#element {
width: 150px;
}
.content-title {
font-weight: 500;
margin-right: 20px;
display: flex;
align-items: center;
}