# ngx-sortablejs **Repository Path**: mirrors_SortableJS/ngx-sortablejs ## Basic Information - **Project Name**: ngx-sortablejs - **Description**: Angular 2+ binding to SortableJS. Previously known as angular-sortablejs - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-18 - **Last Updated**: 2026-01-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ngx-sortablejs This package is an Angular 2+ binding for [Sortable.js](https://github.com/RubaXa/Sortable). Supports standard arrays and Angular `FormArray`. Previously known as angular-sortablejs. ## Demo See the library in action in a [demo](https://sortablejs.github.io/ngx-sortablejs) project (the source is located in `src` directory). Trees are also supported: [tree with fake root element (\*ngFor once, root can also be hidden anyway)](https://stackblitz.com/edit/angular-o1pq84) or [without (\*ngFor 2 times)](https://stackblitz.com/edit/angular-ptu94s). ## Installation ```sh npm i -S ngx-sortablejs sortablejs npm i -D @types/sortablejs ``` You are configured now. If you use Webpack or Angular CLI go to the usage. If you have SystemJS, that's sad, but you can go to the end of the document to find configuration steps there. ## Usage First, import `SortablejsModule.forRoot({ /* and here some global settings if needed */ })` into the root module of your application: ```typescript imports: [ // ... SortablejsModule.forRoot({ animation: 150 }), // ... ] ``` Then import `SortablejsModule` into the other angular modules where you want to use it: ```typescript imports: [ // ... SortablejsModule, // ... ] ``` Then use `sortablejs` property on a container HTML element to tell Angular that this is a sortable container; also pass the `items` array to both `*ngFor` and `[sortablejs]` to register the changes automatically. ## Directive API - `sortablejs` - directive, accepts model to be auto-updated (see examples below) - `sortablejsContainer` - directive input, CSS selector for the sortable container, string. Mostly required for frameworks that wrap the content into the elements where it is impossible to access the real container element (e.g. @angular/material). Example: `sortablejsContainer=".mat-grid-list"` - `sortablejsOptions` - directive input, sortable options to pass in. Please note that in order to change the options later the whole object needs to be recreated, see below - `sortablejsInit` - directive output, returns the current Sortable instance. Example: `(sortablejsInit)="sortableInstance = $event"` ## Simple sortable list ```typescript import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `