I'm attempting to insert a md-button-toggle into a button toggle group programatically with Angular but Create Element doesn't seem to work well with non standard HTML tags.
HTML snippet i'm attempting to append:
<md-button-toggle-group class="toggle-box" [vertical]="true" id="button-toggle-group">
<dash-theme (onSelected)="setTheme($event);sidenav.close()"></dash-theme>
<md-button-toggle routerLink="/admin/dashboard" (click)=sidenav.close()>
Admin Dashboard
</md-button-toggle>
</md-button-toggle-group>
Angular attempt:
// adds a View Dashboard button to the side nav bar when
addViewDashboard(): void {
var node = document.createElement('<md-button-toggle routerLink="/' + this.dashboardName
+ '" (click)=sidenav.close() id="view-dashboard-button"> View Dashboard </md-button-toggle>');
document.getElementById("button-toggle-group").appendChild(node);
}
(this.dashboardName is just a string which will be passed into the router)
I realize CreateElement isn't supposed to work like this and can't really think of how else I can manage to do this.
The end product should be something like:
<md-button-toggle-group class="toggle-box" [vertical]="true" id="button-toggle-group">
<dash-theme (onSelected)="setTheme($event);sidenav.close()"></dash-theme>
<md-button-toggle routerLink="/admin/dashboard" (click)=sidenav.close()>
Admin Dashboard
</md-button-toggle>
<md-button-toggle routerLink="/[this.dashboardName Value]" (click)=sidenav.close() id="view-dashboard-button">
View Dashboard
</md-button-toggle>
</md-button-toggle-group>