Reputation: 1821
I'm trying to use this lib: https://github.com/SortableJS/ngx-sortablejs
I've installed by: npm i ngx-sortablejs sortablejs --save
My page HTML
<div [sortablejs]="items">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
Then I'm importing in my app/app.module.ts
import { SortablejsModule } from 'angular-sortablejs';
...
SortablejsModule.forRoot({ animation: 150 })
And for the last, import module in my page.module.ts
import { SortablejsModule } from 'angular-sortablejs'; <<==== HERE
...
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
SortablejsModule, <<==== AND HERE
...
So the app is compiling with no error but when I try to open the page with component, i get this runtime error:
core.js:15724 ERROR Error: Uncaught (in promise): TypeError: OriginalSortable.create is not a function
TypeError: OriginalSortable.create is not a function
at sortablejs.directive.js:32
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
at NgZone.push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular (core.js:17258)
at SortablejsDirective.push../node_modules/angular-sortablejs/dist/src/sortablejs.directive.js.SortablejsDirective.ngOnInit (sortablejs.directive.js:31)
at checkAndUpdateDirectiveInline (core.js:22099)
at checkAndUpdateNodeInline (core.js:23363)
at checkAndUpdateNode (core.js:23325)
at debugCheckAndUpdateNode (core.js:23959)
at debugCheckDirectivesFn (core.js:23919)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1744)
Am I doing something wrong?
Upvotes: 2
Views: 2284
Reputation: 2203
For me, the error OriginalSortable.create is not a function
appeared after upgrading to Angular 8.
By upgrading ngx-sortablejs
to 3.1.3 and sortablejs
to 1.10.1, the error went away.
Upvotes: 2