Angular imported library with forRoot throwing error [closed]

I fixed it; I was following this article:

https://www.usefuldev.com/post/Angular:%20Creating%20configurable%20libraries%20with%20angular%20cli

If you notice it does declares this constant:

import { InjectionToken } from '@angular/core';
import { NormalLibConfig } from './normal-lib-config';

export const NORMAL_LIB_CONFIG = new InjectionToken(
  'NORMAL_LIB_CONFIG'
);

What I noticed was that even though it imports NormalLibConfig, it never actually uses it. So I googled InjectionToken and found that it’s a generic class. So I updated my implementation to this:

import { InjectionToken } from '@angular/core';
import { ImagesConfig } from './images-config';

export const IMAGES_CONFIG = new InjectionToken<ImagesConfig>('IMAGES_CONFIG');

And that fixed the issue

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top