2016-04-20 16:32:12 +03:00
|
|
|
import {Component, ViewEncapsulation} from 'angular2/core';
|
|
|
|
|
import {RouteConfig, Router} from 'angular2/router';
|
2016-04-29 11:49:49 +03:00
|
|
|
import {Subscription} from 'rxjs/Subscription';
|
|
|
|
|
|
|
|
|
|
import {SidebarStateService} from './theme/sidebar/sidebarState.service';
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-21 20:34:07 +03:00
|
|
|
import {Pages} from './pages';
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-28 13:08:33 +03:00
|
|
|
// TODO: is it really the best place to globally require that dependency?
|
|
|
|
|
require("!style!css!sass!./theme/sass/_ionicons.scss");
|
|
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
/*
|
|
|
|
|
* App Component
|
|
|
|
|
* Top Level Component
|
|
|
|
|
*/
|
2016-04-20 16:32:12 +03:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app',
|
2016-04-29 17:27:19 +03:00
|
|
|
pipes: [],
|
2016-04-29 11:49:49 +03:00
|
|
|
providers: [SidebarStateService],
|
2016-04-20 16:32:12 +03:00
|
|
|
encapsulation: ViewEncapsulation.None,
|
2016-04-29 17:27:19 +03:00
|
|
|
styles: [require('normalize.css'), require('./app.scss')],
|
2016-04-20 16:32:12 +03:00
|
|
|
template: `
|
2016-04-29 11:49:49 +03:00
|
|
|
<main [ngClass]="{'menu-collapsed': isMenuCollapsed}">
|
2016-04-20 16:32:12 +03:00
|
|
|
<router-outlet></router-outlet>
|
|
|
|
|
</main>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
@RouteConfig([
|
2016-04-21 20:34:07 +03:00
|
|
|
{
|
2016-04-28 15:08:48 +03:00
|
|
|
path: '/pages/...',
|
2016-04-21 20:34:07 +03:00
|
|
|
name: 'Pages',
|
|
|
|
|
component: Pages,
|
|
|
|
|
useAsDefault: true
|
|
|
|
|
},
|
2016-04-20 16:32:12 +03:00
|
|
|
])
|
|
|
|
|
export class App {
|
2016-04-29 17:23:33 +03:00
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
isMenuCollapsed:boolean = false;
|
2016-04-29 11:49:49 +03:00
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
private _sidebarStateSubscription:Subscription;
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-29 11:49:49 +03:00
|
|
|
constructor(private _sidebarStateService:SidebarStateService) {
|
|
|
|
|
this._sidebarStateSubscription = this._sidebarStateService.getStateStream().subscribe((isCollapsed) => this.isMenuCollapsed = isCollapsed);
|
|
|
|
|
}
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
ngOnDestroy() {
|
2016-04-29 11:49:49 +03:00
|
|
|
// prevent memory leak when component destroyed
|
|
|
|
|
this._sidebarStateSubscription.unsubscribe();
|
|
|
|
|
}
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|