Topic: Angular modal works in dev mode, but not prod: "Cannot resolve all parameters for 't'"

mrami free asked 5 years ago


MDBootstrap Pro 7.0.0

Angular 6.1.10

Hi,

I have run into an issue with Angular's injection when creating dynamic modals:

test-component.ts:

import {Component} from '@angular/core';
import {MDBModalRef, MDBModalService} from 'ng-uikit-pro-standard';
import {TestPopupComponent} from './test-popup.component';

@Component({
selector: 'app-test-component',
templateUrl: './test.component.html',
})
export class TestComponent {

private modalRef: MDBModalRef;

public constructor(private modalService: MDBModalService) {
}

public openPopup() {
this.modalRef = this.modalService.show(TestPopupComponent, {
class: 'modal-fluid modal-full-height modal-top modal-notify modal-info',
});
}

}

test-popup.component.ts:
import {Component} from '@angular/core';
import {MDBModalRef} from 'ng-uikit-pro-standard';

@Component({
templateUrl: './test-popup.component.html',
})
export class TestPopupComponent {
constructor(public modalRef: MDBModalRef) {
}
}

app.module.ts:

@NgModule({
declarations: [
...
TestComponent,
TestPopupComponent,
],
imports: [
MDBBootstrapModulesPro.forRoot(),
...
],
providers: [MDBSpinningPreloader,
...
],
entryComponents: [
...
TestPopupComponent,
]
})

When I run this, I have a problem with the injection on TestComponent:
core.js:1673 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[TooltipDirective -> ElementRef]:
StaticInjectorError(Platform: core)[TooltipDirective -> ElementRef]:
NullInjectorError: No provider for ElementRef!
Error: StaticInjectorError(AppModule)[TooltipDirective -> ElementRef]:
StaticInjectorError(Platform: core)[TooltipDirective -> ElementRef]:
NullInjectorError: No provider for ElementRef!

If, instead, I make the object myself, it works fine:

public constructor(clf: ComponentLoaderFactory, el: ElementRef, v: ViewContainerRef, r: Renderer2) {
this.modalService = new MDBModalService(clf, el, v, r);
}


What have I missed?

Thanks!

Arkadiusz Idzikowski staff answered 5 years ago


Hi,

Please upgrade to new version. This problem was resolved in 7.1.0.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 7.0.0
  • Device: Desktop
  • Browser: Chrome Version 71.0.3578.98
  • OS: Ubuntu (64 bit)
  • Provided sample code: Yes
  • Provided link: No