Search code examples
angularangular-material2teradata-covalent

Covalent Angular move to own component


maybe I`m trying something totally wrong but I want for example move my toolbar content to my own component. Before:

 <td-layout-nav navigationRoute="/">
        <div td-toolbar-content layout="row" layout-align="start center" flex>
            <button mat-icon-button td-menu-button tdLayoutToggle>
                <mat-icon>menu</mat-icon>
            </button>
            <td-search-box class="pad-top-xs" backIcon="search" placeholder="Search here" [showUnderline]="false" [debounce]="500" [alwaysVisible]="false">
            </td-search-box>
            <button mat-button [matMenuTriggerFor]="menu">Menu</button>
            <mat-menu #menu="matMenu">
                <button mat-menu-item>Item 1</button>
                <button mat-menu-item>Item 2</button>
            </mat-menu>
            <a mat-icon-button matTooltip="Docs" [routerLink]="" href="https://teradata.github.io/covalent/" target="_blank">
                <mat-icon>chrome_reader_mode</mat-icon>
            </a>
        </div>

and my goal is something like
        <td-layout-nav navigationRoute="/">
            <my-own-toolbar-component></my-own-toolbar-component>

The problem now is my layout is getting "destroyed" enter image description here

That's because the content is now surrounded by an additional div from the component selector. But is there a possibility to overcome this? Or is my goal totally wrong? Here is a forked Stackblitz that shows my problem.

Stackblitz


Solution

  • This can be done by using the td-toolbar-content attribute on your component.

    <td-layout-nav navigationRoute="/">
        <my-own-toolbar-component td-toolbar-content></my-own-toolbar-component>
        ...
    </td-layout-nav>