Custom event emitter in Angular Datetimepicker component

21 Sep 20222 minutes to read

The two-way binding in DateTimePicker can also be achieved using the custom event binding and property binding in the controls present in two different components. To create custom event, we need to create an instance of event emitter.

In the following example, property binding is used to share the data from the parent component to the child component using @input directive and custom event binding is used to share the data from the child component to the parent component by using @output directive.

import { Component } from '@angular/core';

    selector: 'app-root',
    template: `
  <div class="parentelement">
   <div class="datevalue">
   <ejs-datetimepicker id="datetime" #datetime (change)="deposit()" placeholder="Parent component" floatLabelType="Always" [value]="value" width="200px"></ejs-datetimepicker>
   <child [xvalue]="value" (valueChange)="valuecheck($event)"> </child>
export class ParentComponent {
    value: Date;
    constructor() {
        this.value = new Date("2/1/2020");
    deposit() {
        this.value = this.Date.value;
    valuecheck(args: any) {
        this.value = args;
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// import the DateTimePickerModule for the DateTimePicker component
import { DateTimePickerModule } from '@syncfusion/ej2-angular-calendars';
import { ParentComponent }  from './app.component';
import { ChildComponent }  from './child.component';

  //declaration of ej2-angular-calendars module into NgModule
  imports:      [ BrowserModule, DateTimePickerModule ],
  declarations: [ ParentComponent,  ChildComponent ],
  bootstrap:    [ ParentComponent]
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';