I am working on developing a custom sticky navbar directive for the sticky header in my angular 6 application.
This is what I have accomplished so far:
import { Directive, Input, Renderer, ElementRef, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { fromEvent } from 'rxjs';
@Directive({
selector: '[ngStickyNav]'
})
export class StickyNavDirective implements OnInit {
private offsetTop: number;
private lastScroll: number = 0;
private isSticky: boolean = false;
@Input('stickyClass') stickyClass: string;
constructor(private elementRef: ElementRef, private renderer: Renderer) {
}
ngOnInit(): void {
this.offsetTop = this.elementRef.nativeElement.offsetTop;
Observable.fromEvent(window, 'scroll').subscribe(() => this.manageScrollEvent());
}
}
However, I am encountering the following error:
Property 'fromEvent' does not exist on type 'typeof Observable'.
Could someone help me identify what might be wrong with my code? Still learning the ropes here!