Smart Toolbar Registry

The Smart Toolbar Registry provides an easy way to obtain a reference to a Smart Toolbar Component, without the need for it to be a direct view child.

 

Obtaining a reference to a Smart Toolbar

HTML Markup
<smart-toolbar smart-object-name="customerToolbar" ... ></smart-toolbar>
import { SmartToolbarComponent, SmartToolbarRegistry, SmartToolbarRegistryEventArgs } from '@consultingwerk/smartcomponents-toolbar';
 
private customertoolbar: SmartToolbarComponent;
 
constructor(private toolbarRegistry: SmartToolbarRegistry) { }
 
ngOnInit() {
	this.toolbarRegistry.toolbarRegistered
			.filter(ev => ev.toolbarName === 'customerToolbar' /** we are only interested in the customer toolbar */)
			.subscribe((ev: SmartToolbarRegistryEventArgs) => {
				this.customerToolbar = ev.toolbar;
 
				//disable the toolbar's add button
				this.customerToolbar.disableButton('add');
 
				//subscribe to a button click event
				this.customerToolbar.cancelButtonClicked(() => { 
						//your custom logic here 
				});
			});
}