shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 241 forks source link

can't used in service(angular5) #432

Open niuwenbo opened 6 years ago

niuwenbo commented 6 years ago

IMPORTANT: Please provide a sample using: http://plnkr.co/edit/lV7zsw7Yqossgs9JOfQU?p=preview

i just injuect a modal into a service refresh page throw this error..can any one has same question?

import { Injectable } from '@angular/core'; import { HttpErrorResponse } from '@angular/common/http';

import { Overlay } from 'ngx-modialog'; import { Modal } from 'ngx-modialog/plugins/bootstrap';

@Injectable() export class ErrorLogService { private name: String = 'ErrorLogService';

constructor(private modal: Modal) {}

}

compiler.js:19550 Uncaught Error: Provider parse errors: Cannot instantiate cyclic dependency! ApplicationRef ("[ERROR ->]"): in NgModule AppModule in ./AppModule@-1:-1 at NgModuleProviderAnalyzer.parse (compiler.js:19550) at NgModuleCompiler.compile (compiler.js:20139) at JitCompiler._compileModule (compiler.js:34437) at eval (compiler.js:34368) at Object.then (compiler.js:474) at JitCompiler._compileModuleAndComponents (compiler.js:34366) at JitCompiler.compileModuleAsync (compiler.js:34260) at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:239) at PlatformRef.bootstrapModule (core.js:5567) at eval (main.ts:11)