Может быть, это поможет тому, кто хочет disable menu item
программно.
Примечание. Используйте одно из событий жизненного цикла Angular с именем ngAfterContentChecked
Шаг 1. В файле component.ts в части экспорта добавьте ngAfterContentChecked
export class AddInCommandsComponent
implements OnInit, AfterViewInit, AfterContentChecked {
И затем добавьте соответствующий импорт
import {
AfterContentChecked,
AfterViewInit,
ChangeDetectorRef,
Component,
OnInit,
} from '@angular/core';
Шаг 2: В том же файле component.ts
ngAfterContentChecked(): void {
this.ref.detectChanges();
this.items = [
{
label: 'Resources',
items: [
{
label: 'Import & Map Resources',
icon: 'ms-Icon ms-Icon--Handwriting ms-fontSize-32 ',
title:
' Retrieves Time Writers',
command: event => this.showMapResourcesScreen(),
disabled: this.noTaskFound,
},
],
},
{
label: 'MS Project to Bamboo',
items: [
{
label: 'Create Project in Bamboo',
icon: 'ms-Icon ms-Icon--Export ms-fontSize-32 ',
title:
'Export all tasks from this project into a new project in Tidy',
command: event => this.showCreateInScreen(),
disabled: this.noTaskFound,
],
},
/* {
label: 'Bamboo to MS Project',
items: [
{
label: 'Import Tasks from Bamboo',
icon: 'ms-Icon ms-Icon--Import ms-fontSize-32 ',
title:
'Import all tasks from Bamboo into a blank project',
command: event => this.showImportFromScreen(),
},
{
label: 'Update Tasks from Bamboo',
icon: 'ms-Icon ms-Icon--PostUpdate ms-fontSize-32',
title:
'Update all tasks in this project from changes made in Bamboo',
disabled: true,
},
],
},*/
];
}
Помните: ngAfterViewInit
выдаст Expression changed error
.
Надеюсь, это поможет.