Render other components in toolbar using angular template in Angular Toolbar component
17 Nov 20223 minutes to read
You can render other components inside Toolbar using Angular ng-template. Through this, we can add items as other components directly with all their functionalities to our Toolbar. We need to use ng-template
inside the each e-item
tag with #template
attribute, which is mandatory to render that template.
import { Component} from '@angular/core';
@Component({
selector: 'app-container',
template: ` <ejs-toolbar>
<e-items>
<e-item >
<ng-template #template>
<ejs-numerictextbox value="10"></ejs-numerictextbox>
</ng-template>
</e-item>
<e-item >
<ng-template #template>
<ejs-datepicker></ejs-datepicker>
</ng-template>
</e-item>
<e-item text='Cut'></e-item>
<e-item text='Copy'></e-item>
<e-item text='Paste'></e-item>
<e-item type='Separator'></e-item>
<e-item text='Bold'></e-item>
<e-item text='Italic'></e-item>
<e-item text='Underline'></e-item>
</e-items>
</ejs-toolbar>`
})
export class AppComponent {
}
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { ToolbarAllModule } from '@syncfusion/ej2-angular-navigations';
import { DatePickerAllModule } from '@syncfusion/ej2-angular-calendars';
import { ButtonAllModule } from '@syncfusion/ej2-angular-buttons';
import { NumericTextBoxAllModule } from '@syncfusion/ej2-angular-inputs';
import { AppComponent } from './app.component';
/**
* Module
*/
@NgModule({
imports: [
FormsModule,
ToolbarAllModule,
BrowserModule,
DatePickerAllModule,
NumericTextBoxAllModule,
ButtonAllModule
],
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);