ngx-admin/src/app/pages/pages.component.ts

58 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-04-21 20:34:07 +03:00
import {Component, ViewEncapsulation} from 'angular2/core';
import {RouteConfig, Router} from 'angular2/router';
import {Dashboard} from './dashboard';
2016-04-27 13:17:51 +03:00
import {PageTop, Sidebar} from '../theme';
2016-04-21 20:34:07 +03:00
/*
* App Component
* Top Level Component
*/
@Component({
2016-04-29 17:08:05 +03:00
selector: 'pages',
encapsulation: ViewEncapsulation.None,
styles: [],
directives: [PageTop, Sidebar],
template: `<sidebar [routes]="getRoutes()"></sidebar><page-top></page-top><router-outlet></router-outlet>`
2016-04-21 20:34:07 +03:00
})
@RouteConfig([
2016-04-29 17:08:05 +03:00
{
path: '/dashboard',
name: 'Dashboard',
component: Dashboard,
useAsDefault: true,
data: {
title: 'Dashboard',
selected: true,
expanded: true,
sidebarMeta: {
icon: 'ion-android-home',
order: 0,
}
}
},
2016-04-21 20:34:07 +03:00
])
export class Pages {
2016-04-29 17:08:05 +03:00
private _routeConfig;
2016-04-29 17:27:19 +03:00
constructor(private _router:Router) {
}
2016-04-29 17:08:05 +03:00
2016-04-29 17:27:19 +03:00
ngOnInit() {
}
2016-04-29 17:08:05 +03:00
getRoutes() {
if (!this._routeConfig) {
this._routeConfig = Reflect.getMetadata('annotations', this.constructor)
.filter(a => {
return a.constructor.name === 'RouteConfig';
})
.pop();
2016-04-21 20:34:07 +03:00
}
2016-04-29 17:08:05 +03:00
return this._routeConfig;
}
2016-04-27 13:17:51 +03:00
}