@mobiage/homescreen
Version:
cp-mbg-homescreen
41 lines (33 loc) • 835 B
text/typescript
export class HomeController {
$bindings: any;
tabs: Array<any> = [];
cards: Array<any>;
chart: any;
config: any;
oi: string;
constructor(public $scope, public $element) { }
$onInit() { }
$onViewInit() {
this.config = this.$bindings.config.tabs;
this.updateConfig();
this.renderTab(0);
}
updateConfig() {
this.tabs = this.config.map((tab) => {
return {
name: tab.name,
};
});
}
renderTab(tabIndex) {
if (this.config[tabIndex]) {
this.tabs.forEach((tab, index) => this.tabs[index].active = false);
this.tabs[tabIndex].active = true;
this.cards = this.config[tabIndex].cards.map((card) => {
return Object.assign({ oi: this.oi }, card);
});
this.chart = this.config[tabIndex].chart;
this.$scope.refresh();
}
}
}