Add link to toolbar item in Angular Toolbar component

28 Sep 20233 minutes to read

You can add link inside Toolbar using Angular ng-template. We need to use ng-template inside the e-item tag with #template attribute, which is mandatory to render the template.

import { Component } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';

@Component({
    selector: 'app-container',
    template: `
        <ejs-toolbar>
          <e-items>
             <e-item text='Cut'></e-item>
             <e-item text='Copy'></e-item>
             <e-item type='Separator'></e-item>
             <e-item text='Paste'></e-item>
             <e-item type='Separator'></e-item>
             <e-item >
            <ng-template #template>
                <div>
                  <a
                    target="_blank"
                    href="https://ej2.syncfusion.com/angular/documentation/toolbar/getting-started/"
                    >Anchor Toolbar Link</a
                  >
                </div>
            </ng-template>
            </e-item>
          </e-items>
        </ejs-toolbar>
        `
})

export class AppComponent {

}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations';
import { AppComponent } from './app.component';

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule, ToolbarModule
    ],
    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);