我已经创建了一个名为 myCustomService 的角度服务,并按照此post所示进行了注册。我没有初始化就获得服务,因此无法从 myCustomService 调用任何方法。 我的自定义服务就是这样
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material';
import { OpenDialogComponent } from '../../components/open-dialog/open-dialog.component';
@Injectable({
providedIn: 'root'
})
export class MyCustomService {
constructor(private dialog: MatDialog) { }
openDialog() {
let dialogRef = this.dialog.open(OpenDialogComponent, {
width: '250px'
});
dialogRef.afterClosed().subscribe((data: boolean) => {
if (data) {
console.log(data);
}
});
}
}
我已经这样注册了此服务
{ [BPMN.InjectionNames.myCustomService]: ['value', BPMN.MyCustomService] },
我已经像这样注入了我的自定义服务
export class RTCamundaPropertiesProvider extends PropertiesActivator {
static $inject = ['MyCustomService', 'eventBus', 'bpmnFactory', 'elementRegistry', 'elementTemplates', 'translate'];
constructor(private myCustomService: MyCustomService, private eventBus: any, private bpmnFactory: any, private elementRegistry: any, private elementTemplates: any, private translate: any) {
super(eventBus);
this.myCustomService.openDialog();
}
}
提前谢谢
Nagu