View on GitHub

angular-nestable

Angular module for jQuery nestable plugin

Download this project as a .zip file Download this project as a tar.gz file

Demo:

{{$item.text}}

angular-nestable 0.0.1

DESCRIPTION:

angular-nestable is a module for AngularJS that uses the jQuery nestable plugin to create multi-sortable lists with the ability to nest items within each other.

USAGE:

<div ng-nestable ng-model="items">
    <div>
        <!-- this element is the template for each menu item -->
        <!-- the $item is available on scope and is the reference to the menu item object -->
        {{$item}}
    </div>
</div>

Example items object structure:

[
    {
        item: {}, // this object will be referenced as the $item on scope
        children: []
    },
    {
        item: {},
        children: [
            {
                item: {},
                children: []
            }
        ]
    },
    {
        item: {},
        children: []
    }
]

Each nestable element in the DOM gets it's own non-isolated scope just like with ng-repeat.

Also the options object can be passed to the directive as the ng-nestable attribute. Those options will be passed to the jQuery nestable function when creating a nestable.

The module also exposes a $nestableProvider that can be injected into a config block. It provides two methods:

Also note that the ng-sortable directive uses ngModelController to read and write to the provided model object and is fully compliant with $formatters and $parsers.