Add link to toolbar item in EJ2 TypeScript Toolbar control
20 Dec 20243 minutes to read
Toolbar supports to add link by using the template configuration. The Toolbar can be rendered by item based collection and by HTML elements. Template property can be given as the HTML element that is either a string or a query selector.
The template property also allows getting template content through query selector. Here, anchor element ‘ID’ attribute is specified in the template.
The Toolbar supports adding links using the template configuration. It can be rendered by either item-based collections or HTML elements.The template property can be specified as an HTML element, either as a string or a query selector. The template property also allows obtaining template content through a query selector. Here, the anchor element’s ‘ID’ attribute is specified in the template.
template: "#AnchorTemplate"import {Toolbar} from '@syncfusion/ej2-navigations';
let toolbar: Toolbar = new Toolbar({
items: [
{ text: "Cut" },
{ text: "Copy" },
{ type: "Separator" },
{ text: "Paste" },
{ type: "Separator" },
{ template: '#AnchorTemplate' }
]
});
toolbar.appendTo('#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 Toolbar</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript Toolbar Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/31.2.2/material.css" rel="stylesheet" />
<link href="https://ej2.syncfusion.com/angular/demos/src/toolbar/toolbar.component.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>LOADING....</div>
<div id='container'>
<div id='element'></div>
<div id='AnchorTemplate'>
<a target="_blank"
href="https://ej2.syncfusion.com/documentation/toolbar/getting-started/">Anchor Toolbar Link</a>
</div>
<br/><br/>
</div>
</body>
</html>