I'm trying to use this 'BsModalService' to open a modal, but I'm getting the following error.
compiler.js:485 Uncaught Error: Can't resolve all parameters for AppComponent: (?, [object Object], [object Object]).
Here is My component.
import { Component, ViewChild, HostListener, OnInit, Inject, ElementRef, TemplateRef } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
import { WINDOW } from "../providers/window.service";
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app';
isCollapsed: boolean;
magicHeight: number;
invertNavBar: boolean = false;
modalRef: BsModalRef;
@ViewChild('navBar') navBarElementView: ElementRef;
@ViewChild('funcionalidades') funcionalidadeselementView: ElementRef;
constructor(
private modalService: BsModalService,
@Inject(DOCUMENT) private document: Document,
@Inject(WINDOW) private window
) {
}
}
And here my module.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { CarouselModule } from 'ngx-bootstrap/carousel';
import { ModalModule } from 'ngx-bootstrap/modal';
import { ModalPrincipalComponent} from '../components/modal_principal/modal_principal.component';
import { AppComponent } from './app.component';
import { WINDOW_PROVIDERS } from "../providers/window.service";
@NgModule({
declarations: [
AppComponent,
ModalPrincipalComponent
],
imports: [
BrowserModule,
ModalModule.forRoot(),
CollapseModule.forRoot(),
CarouselModule.forRoot()
],
providers: [WINDOW_PROVIDERS],
bootstrap: [AppComponent]
})
export class AppModule { }
An interesting thing about this, is that if I add modalService as the last parameter in my constructor, I don't get this error, but the service still isn't injected, the variable value become undefined.
The library in general is working, I'm using carousel and collapse modules without any problem.
I've already tried to delete the node_modules folder and reinstall it, but didn't solve the problem.