ng-material-multilevel-menu не работает в Angular 7

Я использую этот плагин для многоуровневого меню в Angular 7. Он отлично работает при выполнении ng serve, но не работает при выполнении ng build.
Получение этой ошибки при сборке с использованием ng build --configuration = dev.

ERROR in src\app\sidemenu\sidemenu.component.html(8,76): : Property 'selectedItem' does not exist on type 'SidemenuComponent'.
src\app\sidemenu\sidemenu.component.html(8,114): : Property 'selectedLabel' does not exist on type 'SidemenuComponent'.

Также появляется предупреждение ниже при выполнении npm install.

npm WARN [email protected] requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.

Вот моя конфигурация разработчика в angular.json

"dev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }

Вот sidemenu.component.html

<mat-nav-list style="padding-top:0px !important;">
    <a mat-list-item (click)="toggleText()">
      <i *ngIf=!showText class="material-icons" aria-label="Show icon only">chevron_right</i>
      <i *ngIf=showText class="material-icons" aria-label="Show icon and text">chevron_left</i>
    </a>
  </mat-nav-list>

  <ng-material-multilevel-menu [configuration]='config' [items]='appitems' (selectedItem)="selectedItem($event)" (selectedLabel)="selectedLabel($event)">
  </ng-material-multilevel-menu>

А вот и файл ts. Пожалуйста, посоветуйте, что я делаю не так.

import { Component, OnInit } from '@angular/core';
import { ElementRef } from '@angular/core';

@Component({
  selector: 'app-sidemenu',
  templateUrl: './sidemenu.component.html',
  styleUrls: ['./sidemenu.component.css'],
})
export class SidemenuComponent implements OnInit {
  showText = true;
  appitems: any[];
  config: any;
  constructor(private el: ElementRef) {}
  ngOnInit() {
    this.appitems = [
      {
        label: 'Dashboard',
        icon: 'dashboard',
        link: 'dashboard',
      },
      {
        label: 'Create Order',
        icon: 'shopping_cart',
        link: 'order',
      },
      {
        label: 'Search',
        icon: 'image_search',
        items: [
          {
            label: 'Order Search',
            icon: 'search',
            link: 'order-search',
          },
          {
            label: 'Job Search',
            icon: 'search',
            link: 'job-search',
          },         
        ],
      },

    ];
    this.config = {
      interfaceWithRoute: true,
      classname: 'side-menu-class',
      listBackgroundColor: `#12517c`,
      fontColor: `white`,
      backgroundColor: `#12517c`,
      selectedListFontColor: `red`,
    };
  }
  toggleText() {
    this.showText = !this.showText;
    const elements = this.el.nativeElement.querySelectorAll('.label');
    const htmlElements = Array.from(elements).map(x => x as HTMLElement);
    htmlElements.forEach(label => (label.hidden = !this.showText));
  }
}

person jijo    schedule 16.01.2019    source источник


Ответы (1)


Приведенные ниже предупреждения не связаны с вашим проектом, а не с его плагином. Плагин необходимо обновить с учетом его зависимостей. Я сделаю это как можно скорее.

npm WARN [email protected] requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.

Что касается указанной выше ошибки, методы selectedItem() и selectedLabel() не определены в классе компонентов SideMenu.

Спасибо,

Изменить 1:

Вам необходимо самостоятельно установить одноранговые зависимости

person Shanky    schedule 24.01.2019
comment
предупреждения о версии все еще присутствуют на 4.9.2 - person Monish Sen; 26.01.2019
comment
npm WARN [email protected] требует однорангового узла @ angular / common @ ^ 6.0.0-rc.0 || ^ 6.0.0, но ничего не установлено. Вы должны сами установить одноранговые зависимости. npm WARN [email protected] требует однорангового узла @ angular / core @ ^ 6.0.0-rc.0 || ^ 6.0.0, но ничего не установлено. Вы должны сами установить одноранговые зависимости. - person Monish Sen; 26.01.2019
comment
@Shanky - Не могли бы вы проверить мой вопрос stackoverflow.com/questions/60336154/ - person R15; 21.02.2020