Mike3355
Mike3355

Reputation: 12101

No provider for ComponentLoaderFactory

I updated my angular2 project and before it was working fine. However now I am getting the following error:

Error: Uncaught (in promise): Error: Error in ./RibbonComponent class 
RibbonComponent - inline template:4:5 caused by: No provider for 
ComponentLoaderFactory!
Error: Error in ./RibbonComponent class RibbonComponent - inline 
template:4:5 caused by: No provider for ComponentLoaderFactory!

ComponentLoaderFactory

export declare class ComponentLoaderFactory {
    private _componentFactoryResolver;
    private _ngZone;
    private _injector;
    private _posService;
    constructor(componentFactoryResolver: ComponentFactoryResolver, ngZone: NgZone, injector: Injector, posService: PositioningService);
    /**
     *
     * @param _elementRef
     * @param _viewContainerRef
     * @param _renderer
     * @returns {ComponentLoader}
     */
    createLoader<T>(_elementRef: ElementRef, _viewContainerRef: ViewContainerRef, _renderer: Renderer): ComponentLoader<T>;
}

I am not sure what else to post. All my made my package.json up to date via ncu than ncu -u. I am being to think I found a bug. I did find a post on GitHub but it did not help. GitHub

If I need to post anything else let me know.

Upvotes: 17

Views: 19721

Answers (4)

Richard Matsen
Richard Matsen

Reputation: 23483

Not sure what libraries you are using, but I had this error when using ng2-bootstrap.

I got the solution from this page: angular-2-with-ng2-bootstrap-and-karma-testing-final-adventure.

Essentially the problem was with an import that required the .forRoot() method to be called. Maybe look for something similar in the RibbonComponent or other imported library.

Upvotes: 41

Francesco Borzi
Francesco Borzi

Reputation: 61954

In my case my test was missing this import:

TooltipModule.forRoot()

it is strange that for other modules, such as ModalModule, I get a proper error that points me to the missing provider, but not for this one.

Upvotes: 3

mruanova
mruanova

Reputation: 7105

import modal module in your spec.ts file like this:

import { ModalModule } from 'ngx-bootstrap';
....
imports: [ModalModule.forRoot()],

Upvotes: 5

Alok Kamboj
Alok Kamboj

Reputation: 1027

for example is you are using modal of ngx-bootstrap then you should import the module in spec.ts like :-

ModalModule.forRoot()

Hope this helps

Upvotes: 21

Related Questions