src/app/modules/search/search.component.ts
Компонент-оболочка для поиска
styleUrls | search.scss |
templateUrl | ./search.html |
Properties |
Methods |
constructor(route: ActivatedRoute, profileService: ProfileService, settingsService: SettingsService)
|
||||||||||||
Конструктор
Parameters :
|
ngOnInit |
ngOnInit()
|
Подгружаем нужное меню
Returns :
void
|
menu |
menu:
|
Type : any
|
Меню |
mode |
mode:
|
Type : string
|
Default value : search
|
Режим работы для меню |
profile |
profile:
|
Type : any
|
Профиль |
role |
role:
|
Type : string
|
Роль |
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/switchMap';
import { ProfileService } from 'glx.ui/components/kernel/services/profile.service';
import { SettingsService } from 'glx.ui/components/kernel/services/settings.service';
import { MENU } from './menu';
/**
* Компонент-оболочка для поиска
*/
@Component({
templateUrl: './search.html',
styleUrls: ['./search.scss']
})
export class SearchComponent implements OnInit {
/**
* Меню
* @type {Array}
*/
menu: any = [];
/**
* Режим работы для меню
* @type {string}
*/
mode: string = 'search';
/**
* Профиль
*/
profile: any;
/**
* Роль
* @type {string}
*/
role: string = '';
/**
* Конструктор
* @param {ActivatedRoute} route
* @param {ProfileService} profileService
* @param {SettingsService} settingsService
*/
constructor(private route: ActivatedRoute,
private profileService: ProfileService,
private settingsService: SettingsService) {
}
/**
* Подгружаем нужное меню
*/
ngOnInit() {
if (this.route.snapshot.paramMap.get('mode')) {
this.mode = this.route.snapshot.paramMap.get('mode');
}
this.menu = MENU[this.mode];
this.settingsService.getSection('common')
.subscribe(
data => {
this.menu = data.searchMenu[this.mode];
},
error => {
console.error(error);
});
}
}
<glx-top-menu-bx [items]="menu"></glx-top-menu-bx>
<div class="container-fluid">
<router-outlet></router-outlet>
</div>