Skip to content

Commit 8a58865

Browse files
committed
Added check whether we are on browser
1 parent bb655ae commit 8a58865

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib/sticky-header/sticky-header-dir.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
import {Directive, Input,
99
OnDestroy, AfterViewInit, ElementRef, Optional} from '@angular/core';
10+
import {Platform} from '../core/platform';
1011
import {Scrollable} from '../core/overlay/scroll/scrollable';
1112
import {extendObject} from '../core/util/object-extend';
1213
import {Observable} from 'rxjs/Observable';
@@ -96,10 +97,13 @@ export class CdkStickyHeader implements OnDestroy, AfterViewInit {
9697

9798
constructor(element: ElementRef,
9899
scrollable: Scrollable,
99-
@Optional() public parentRegion: CdkStickyRegion) {
100-
this.element = element.nativeElement;
101-
this.upperScrollableContainer = scrollable.getElementRef().nativeElement;
102-
this.setStrategyAccordingToCompatibility();
100+
@Optional() public parentRegion: CdkStickyRegion,
101+
platform: Platform) {
102+
if (platform.isBrowser) {
103+
this.element = element.nativeElement;
104+
this.upperScrollableContainer = scrollable.getElementRef().nativeElement;
105+
this.setStrategyAccordingToCompatibility();
106+
}
103107
}
104108

105109
ngAfterViewInit(): void {

0 commit comments

Comments
 (0)