mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-23 02:40:14 +01:00
dynamic menu items
This commit is contained in:
parent
6571796ca6
commit
91c652166d
3 changed files with 57 additions and 48 deletions
|
|
@ -9,20 +9,47 @@ import {PageTop, Sidebar} from '../theme';
|
|||
* Top Level Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'pages',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
styles: [],
|
||||
directives: [PageTop, Sidebar],
|
||||
template: `<sidebar></sidebar><page-top></page-top><router-outlet></router-outlet>`
|
||||
selector: 'pages',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
styles: [],
|
||||
directives: [PageTop, Sidebar],
|
||||
template: `<sidebar [routes]="getRoutes()"></sidebar><page-top></page-top><router-outlet></router-outlet>`
|
||||
})
|
||||
@RouteConfig([
|
||||
{ path: '/dashboard', name: 'Dashboard', component: Dashboard, useAsDefault: true },
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'Dashboard',
|
||||
component: Dashboard,
|
||||
useAsDefault: true,
|
||||
data: {
|
||||
title: 'Dashboard',
|
||||
selected: true,
|
||||
expanded: true,
|
||||
sidebarMeta: {
|
||||
icon: 'ion-android-home',
|
||||
order: 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
])
|
||||
export class Pages {
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
console.log('Pages');
|
||||
private _routeConfig;
|
||||
|
||||
constructor(private _router: Router) { }
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
getRoutes() {
|
||||
|
||||
if (!this._routeConfig) {
|
||||
this._routeConfig = Reflect.getMetadata('annotations', this.constructor)
|
||||
.filter(a => {
|
||||
return a.constructor.name === 'RouteConfig';
|
||||
})
|
||||
.pop();
|
||||
}
|
||||
|
||||
return this._routeConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue