I'm using a TabView component with template syntax to iterate over it and add items inside (using an observable collection and async pipe). My items come from a http request.
My home.component.tns.html as follows:
<ActionBar title="Angular 2 Seed Advanced (nativescript)">
</ActionBar>
<StackLayout>
<TabView selectedIndex="0" selectedColor="#FF0000">
<template ngFor let-tab [ngForOf]="tabs | async">
<StackLayout *tabItem="tab">
<Label text="tab item"></Label>
</StackLayout>
</template>
</TabView>
<Button text="call something" (tap)="emptymethod()"></Button>
</StackLayout>
...and my home.component.ts:
...
export class HomeComponent{
public tabs: Observable<any[]>;
constructor(private _menuService: MenuService) {
this._menuService.getMenu()
.map((menus) => {
let result: Array<any> = [];
if (menus) {
menus.forEach(menu => {
result.push({ 'title': menu.title });
});
}
return result;
})
.subscribe(
data => {
this.tabs = Observable.of<any[]>(data);
},
error => error => this._log.debug(error));
}
emptymethod() {
this._log.debug('HomeComponent - nada invoked');
}
ngOnInit() {
}
...
When the interface is renderized, the TabView menu does not appears, but when i click over call something button and emptymethod is called the items inside the TabView appears, in other words, after the "refresh" that component appears...
This should not happens automatically?