javascript - dynamically add item to angularjs ng-repeat -


i have directive generates drag/drop reorderable list add , remove functionality. if click in container, input added dynamically, type in , when type comma, value typed pushed list used ng-repeat build list. (should kinda familiar users of site :) )

this works awesome when initial object backing not null. when object begins null , try add first item (by detecting null , scope.$apply initialization)the markup not generated.

here plunk show mean. http://plnkr.co/edit/momlgpfy82khrpwxgr8v?p=preview

in app, data coming external source, can't ensure non-null lists. how can angular respond array initialization (and later push)?

set list empty array...whenevr new item pushed array angular listeners update directive

http://plnkr.co/edit/h3goptx6chh1wjcm9qrv?p=preview


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -