zurfyx / angular-contents

Angular 5 Table of Contents that follows you while you scroll down
https://zurfyx.github.io/angular-contents
MIT License
40 stars 10 forks source link

no provider for ContentsDirective when using contentsLink #3

Closed gagandeepgill closed 6 years ago

gagandeepgill commented 6 years ago

I get this error while using contentsLink, I have imported your package correctly. All the other directives work fine but this one is giving me issues.

capture

zurfyx commented 6 years ago

Hi gagandeepgill,

Is this a specific extension? I'd like to try it out. My vscode doesn't notify me of such errors.

I find it strange that you get a provider error when this library is fully about directives. I have just had a look at the implementation of this particular directive and maybe it might be because of rxjs missing, which I forgot to add to peer dependencies. From v2.0.1 you'll be warned to install rxjs ^5.5.2.

Do you get any console error too that gives more information than this? Also, if you can get a sample uploaded somewhere I might be able to find out more about your particular issue.

gagandeepgill commented 6 years ago

image

this is what I get from console in chrome and I also have rxjs it up to date.

image

zurfyx commented 6 years ago

That's very weird. I'd like to see a full working version to test it myself.

Does your @Module and @Component look like the ones in the example?

Your component's module (where you are using it), should have the single ContentsModule import, component should have nothing special.

YourModule.module.ts

import { ContentsModule } from 'angular-contents';

@NgModule({
  imports: [
    ContentsModule, // Importing this single module will add all library directives that are required.
  ],
  declarations: [
        // Angular Contents requires no declarations.
  ],
  providers: [], // Angular Contents has no providers.
})
export class YourModuleModule { }

You've probably done already, but I encourage you to have a second in-depth look at the example code and see if there's something different in your project. The demo code is the one that is running on GitHub Pages, which is working fine. So if you do just like in the demo it should work well.

gagandeepgill commented 6 years ago

I solved the problem, I was using another module for routing apps and I had to import your package in there as well. I wouldn't have looked into it if you haven't told me to look at my modules again.

Thanks for the help!

zurfyx commented 6 years ago

I'm glad that you managed to solve it! Happy coding :D