0

I have been trying to make the ngx-perfect-scrollbar work. I have installed the library using

npm install ngx-perfect-scrollbar --save

after that I have added the dependency into my app.module.ts. But when i run the app it gives error

Object(...) is not a function

I don't know what I am doing wrong here. All the steps have been followed as per in github repo.

This is the error that I am seeing

Error is generated from line number 126

ngx-perfect-scrollbar file code

This is my html file

<div class="ps" style="position: relative; max-width: 600px; max-height: 400px;" [perfectScrollbar]="config">
    <router-outlet></router-outlet>
 </div>
James Z
  • 12,209
  • 10
  • 24
  • 44
Unnikrishnan M R
  • 224
  • 2
  • 11
  • 1
    Why is the question down voted? Can i know the reason – Unnikrishnan M R Apr 10 '18 at 10:13
  • Please show the typescript code of the component and not the compiled js in the browser. My guess is that the `config` parameter that you pass to the `[perfectScrollbar]` directive doesn't exist on the scope of the component. You can use the directive also without passing the config element to it by simply adding it as `perfectScrollbar` without the brackets and the equal sign after it. – Ori Shalom Sep 11 '18 at 23:36

2 Answers2

1

Add these line to your component header:

import { fromEvent } from 'rxjs/observable/fromEvent';
import { merge } from 'rxjs/observable/merge';

require('rxjs').fromEvent = fromEvent
require('rxjs').merge = merge

source

MortezaDalil
  • 352
  • 1
  • 2
  • 16
0

I had the same issue when running Angular 5. I had installed ngx-perfect-scrollbar 6.x, downgrading with the following commands resolved the issue for me:

npm remove ngx-perfect-scrollbar

npm install --save ngx-perfect-scrollbar@^5.0.0
Cray
  • 2,774
  • 7
  • 22
  • 32