JonnyBGod / ngx-scrollspy

Angular ScrollSpy Service
MIT License
94 stars 21 forks source link

scrollSpyService.getObservable('window') returns Undefined #106

Closed DaEkstrim closed 7 years ago

DaEkstrim commented 7 years ago

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'));
}
DaEkstrim commented 7 years ago

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.