JonnyBGod / ngx-scrollspy

Angular ScrollSpy Service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scrollSpyService.getObservable('window') returns Undefined

DaEkstrim opened this issue · comments

When I call the getObservable('window') in the ScrollSpyService, the service is returning 'undefined'. Can you please point out what the issue mightbe? Here's my setup:

Module:

import { ScrollSpyModule } from 'ng2-scrollspy';
...
@NgModule({
    imports: [
        ScrollSpyModule.forRoot(),

Component:

import { ScrollSpyService } from 'ng2-scrollspy';
...
constructor(private scrollSpyService: ScrollSpyService) {
    }
...
ngAfterViewInit() {
    console.log(this.scrollSpyService.getObservable('window'));
}

Upon further analysis of the documentation, I found that I was omitting the ScrollSpyDirective from the template. Once added, the function getObservable('window') returns an object correctly.