0

I have a angular 2 app where I'm trying to implement a very simple animated scroll, using ng2-page-scroll.

According to the read.me, I should be able to npm install it, Import it to my module.ts file and then user the directive.

I've done all of that, but I get nothing.

Has anyone used this package and gotten it to work?

Here is my import:

import {Ng2PageScrollModule} from 'ng2-page-scroll/ng2-page-scroll';

I have it properly added in the module "import" section...

Here is my anchor link with directive:

 <a href="#test" pageScroll> test </a>

and my anchor element has id="test"

Any thoughts?

cnak2
  • 1,711
  • 3
  • 28
  • 53

1 Answers1

0

If the component trying to use Ng2PageScroll is not a part of your app root module, I found that you had to add Ng2PageScrollModule to the "imports" section of the module that this component is a part of.

So for example, if you have app.module.ts which defines the root module of your app, and then you have feature-area-1.module.ts which defines a feature area module, and you want to use Ng2PageScroll in a component that is listed in the "declarations" section of the module defined in feature-area-1.module.ts, then try adding Ng2PageScrollModule to the "imports" section of the module defined in feature-area-1.module.ts.

Alternatively, try using the "Service" method described in their documentation as opposed to trying to use the directives.

Sean
  • 498
  • 1
  • 5
  • 13