I use ionic2 & angular2 to build app, I want to define a custom component like ion-navbar, which can append title and buttons in it, just like:
<t-nav>
<t-title>title for custom nav</t-title>
<t-buttons></t-buttons>
</t-nav>
with a custom component
@Component({
selector: 't-nav',
template: '<div>dummy</div><div>dummy</div>'
})
export class TNav {
}
But after ionic build, the content in t-nav was missing, only remains
<t-nav>
<div>dummy</div><div>dummy</div>
</t-nav>
So can anybody tell me how does the angular2 framework keep DOM elements in ion-nav and ion-buttons while template is not empty?
Some code from ionic-angular package, nav.js, it seems template is not empty
Navbar.decorators = [
{ type: Component, args: [{
selector: 'ion-navbar',
template: '<div class="toolbar-background" [ngClass]="\'toolbar-background-\' + _mode"></div>' +
'<button (click)="backButtonClick($event)" ion-button="bar-button" class="back-button" [ngClass]="\'back-button-\' + _mode" [hidden]="_hideBb">' +
'<ion-icon class="back-button-icon" [ngClass]="\'back-button-icon-\' + _mode" [name]="_bbIcon"></ion-icon>' +
'<span class="back-button-text" [ngClass]="\'back-button-text-\' + _mode">{{_backText}}</span>' +
'</button>' +
'<ng-content select="[menuToggle],ion-buttons[left]"></ng-content>' +
'<ng-content select="ion-buttons[start]"></ng-content>' +
'<ng-content select="ion-buttons[end],ion-buttons[right]"></ng-content>' +
'<div class="toolbar-content" [ngClass]="\'toolbar-content-\' + _mode">' +
'<ng-content></ng-content>' +
'</div>',
host: {
'[hidden]': '_hidden',
'class': 'toolbar',
'[class.statusbar-padding]': '_sbPadding'
}
},] },
];
and also in html we can nest elements like
<ion-navbar>
<button ion-button icon-only menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>
Page Title
</ion-title>
<ion-buttons end>
<button ion-button icon-only (click)="openModal()">
<ion-icon name="options"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
Any help will be appreciate.