4

How to import https://anseki.github.io/plain-draggable/ in angular ?

I've npm i plain-draggable then import in angular.json the .min.js

In html

  <span id="draggable" style="background-color: lightskyblue;">adipiscing</span>
  elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
  enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
  aliquip ex ea commodo consequat.</p>

And in component : declare const PlainDraggable: any;

then called in constructor PlainDraggable()

I get the error Cannot call a class as a function

1
  • 1
    new PlainDraggable() Commented Aug 20, 2020 at 8:56

1 Answer 1

4

Instead of calling it on your constructor, try calling it on your AfterViewInit hook like this:

ngAfterViewInit() {
    const draggable = new PlainDraggable(document.getElementById('draggable'));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.