javascript - How to move an object to the top of an array with AngularFire? -


i trying move object top of array angularfire.

my array in firebase simmilar this:

$scope.todos = [     {title:"work out", timetag:"new date()", done: false },     {title:"home work", timetag:"new date()", done: false } ]; 

i created function uses vanilla javascript stores object variable. function deletes object array want move beginning of array. function replaces object stored variable beginning of array.

here code have:

$scope.moveuppriority = function($index){     var tomove = $scope.todos[$index];     delete $scope.todos[$index];     $scope.todos.splice(0,0, tomove);     $scope.todos.$save();   }; 

this code snippet working way want. when run on todo list, moves todo task array. when refresh page, doesn't stick.

what appropriate angularfire methods save or set type of javascript code firebase backend?

to preserve order of todos add property named example priority.

when todo dragged/moved priority list should re-set priority values of todos save them , order them property in template.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -