0

I have updated my application from angular 4.4 to angular 5.2 by updating package.json file but getting this error Uncaught Error: Can't resolve all parameters for DialogService: (?, ?, ?)

Dialog-service.ts is below

import {Injectable, Component} from '@angular/core';
import {MatDialog, MatDialogConfig, MatDialogRef} from '@angular/material';
import {ConfirmService} from './confirm.service';
import {GuideService} from '../guides/guides.service';
@Injectable()
@Component({
    templateUrl: 'dialog.component.html',
    styleUrls: ['confirm.component.scss']
})
export class DialogComponent {
    constructor(private confirmService: ConfirmService,
                private guideService: GuideService,
                private dialogService: DialogService) {
        this.msg = confirmService.msg;
        this.guideService.isConfirmBoxOpen.next(true);
    }

    public msg: string;

    closeDialog() {
        this.dialogService.dialogRef.close();
    }


    continue() {
        this.guideService.isConfirmBoxOpen.next(false);
        this.dialogService.dialogRef.close('continue');
    }

}

export class DialogService {
    dialogRef: MatDialogRef<DialogComponent>;

    constructor(private mdDialog: MatDialog,
                private confirmService: ConfirmService,
                private guideService: GuideService) {
    }

    confirm(message?: string) {
        this.guideService.isConfirmBoxOpen.next(true);
        this.confirmService.options = {
            ok: false,
            yes: true,
            cancel: true
        };

        return new Promise<boolean>(resolve => {
            this.dialogRef = this.mdDialog.open(DialogComponent, <MatDialogConfig>{
                height: '350px',
                width: '700px',
            });
            this.dialogRef.afterClosed().subscribe((value) => {
                if (value === 'continue') {
                    return resolve(true);
                } else {
                    return resolve(false);
                }
            });
        });
    }
}

I have already tried many versions of angular material and angular other versions, but couldn't find any solution. Is there anything wrong with dialog-service or angular material version 5.2.5 . I am using angular 5.2.10 with material 5.2.10 . Can anyone please help?

Shifali singla
  • 76
  • 1
  • 2
  • 8
  • This sounds like an Injection problem in a service, not a missing dependency. The package.json is not relevant here. Post the DialogService please and the module-file in which it is used. – Phil May 04 '18 at 11:56
  • 2
    Most likely your angular version is not compatible with material cdk version. – Niladri May 04 '18 at 12:01
  • @Phil Hi, I have edited and posted dialogService here, it is used as this.dialogService.confirm('sure'); in so many components of application – Shifali singla May 07 '18 at 10:22

0 Answers0