diff --git a/src/angular-nestable.js b/src/angular-nestable.js index e32f367..968bcc3 100644 --- a/src/angular-nestable.js +++ b/src/angular-nestable.js @@ -184,6 +184,12 @@ function buildNestableHtml(model, tpl){ var root = $('
'); + // create placeholder if the list is empty + if (!model.length) { + $('
').appendTo(root); + return root; + } + // create nested hierarchy var rootList = $('
    ').appendTo(root); model.forEach(function f(item){ var list = Array.prototype.slice.call(arguments).slice(-1)[0];