Angular Sortablejs directive

GitHub license  npm  scope

This package provides Angular binding for Storablejs which works with standard arrays as well as Angular FormArray objects.


Demo


Basic usage

View on GitHub

This examples shows various elements that can be sortable. They share the same model, so reordering elements in one container propagates to all other containers in the example.

Button groups





Cards

Ankara
Ankara description
Moscow
Moscow description
Munich
Munich description
Paris
Paris description
Washington
Washington description

Navigation

The actual model

Sortable FormArray

View on GitHub

Most of the time one wants to sort something more than just data. Complex form inputs with FormArray controls are also supported.


FormArray value

Disabled options

View on GitHub
  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5

The actual model

Events

View on GitHub

Binding to the events is easy. Any even could be attached as a property of Sortablejs. The example below binds to the onUpdate event. Drag the items and track the amount of updates.


  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5

Hint: for the FormArray using onUpdate is kinda overhead because the FormArray.valueChanges provides an event on every change.

Scrolling options

View on GitHub

Most browsers automatically scroll content as you drag items to the edge of the screen. If the default behaviour doesn't work for you, Sortablejs provides an option to cofigure scrolling.

  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5
  • Element 6
  • Element 7
  • Element 8
  • Element 9
  • Element 10
  • Element 11
  • Element 12
  • Element 13
  • Element 14
  • Element 15
  • Element 16
  • Element 17
  • Element 18
  • Element 19
  • Element 20
  • Element 21
  • Element 22
  • Element 23
  • Element 24
  • Element 25
  • Element 26
  • Element 27
  • Element 28
  • Element 29
  • Element 30

Transfer between lists

View on GitHub

These lists are connected together. You can drag / drop elements across the lists.

  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5
  • Element 6
  • Element 7
  • Element 8
  • Element 9
  • Element 10

List states

Clone items

View on GitHub

The first list is a clone factory, and the second list can be its target.

  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5
  • Element 6
  • Element 7
  • Element 8
  • Element 9
  • Element 10

List states

Complex example

View on GitHub

Each list can have different options and restrictions.

1. This list cannot accept items
  • Element 1
  • Element 2
  • Element 3
  • Element 4
  • Element 5
2. This is a normal list
  • Element 6
  • Element 7
  • Element 8
  • Element 9
  • Element 10
3. This list clones its children
  • Element 11
  • Element 12
4. Only items from #1 can be put here
  • Element 13

List states

Union example

View on GitHub

The list items can be of different types (the element type can be a union type).



The actual model

Table items

View on GitHub

Table rows are nested inside tbody, and require the container selector to be set accordingly.

CityDescription
AnkaraAnkara description
MoscowMoscow description
MunichMunich description
ParisParis description
WashingtonWashington description