MenuService function/how to use

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
aktaeon
Posts: 1
Joined: 17 Mar 2021, 21:34

27 May 2021, 00:41

I see in the code that there is a MenuService, see code below, and I see that it is used in the menu-items. What is the function of the service and how would I use it to create new menus for for example the top-navbar ?

Code: Select all

import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable()
export class MenuService {

  private menuSource = new Subject<string>();
  private resetSource = new Subject();

  menuSource$ = this.menuSource.asObservable();
  resetSource$ = this.resetSource.asObservable();

  onMenuStateChange(key: string) {
    this.menuSource.next(key);
  }

  reset() {
    this.resetSource.next();
  }
}

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

04 Jun 2021, 13:50

Hi,
These functions and MenuService use to select an active menu item in nested menu type or route navigation item. Also, these used to reset the menu after selection in horizontal mode. You can use the same way for you want functionalities.

Post Reply

Return to “Ultima - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests