I'm thinking how I can apply a partial update of an item in $ firebaseArray
, And the documents do not mention any of this. . $ Save
seems to stop the whole item:
var ref = new Firebase ("https://xxxx.firebaseio.com/items"); $ Scope.items = $ firebaseArray (ref); SomeItem = getItem (); SomeItem.newField = 'test'; . Save $ scope.items $ (someItem); This causes the whole object to be completely overridden, just updating newField
Instead of how I have seen it using $ asObject
, but I still have a $ firebaseArray
I think I can help here. First, some things:
- I do not use your
getItem ()
and thereforeis not some item
$ Id
property, properties ofsome items
can be set as properties of$ scope.items
. - You
. $ Add (someItem) can add
toitemsArray
if you want to create a new item. - You can
$ scope.items. $ Save (someItem) can be used
ifsome item
has$ id
.
code
reef = new firebase (FBURL + '/ item'); ItemsList = $ firebaseArray (referee); $ Scope.items = item list; $ Scope.addItemObject = function () {var someItem = {}; SomeItem.newField = 'test'; . ItemsList $ add (someItem); Console.log ('$ scope.items is', $ scope.items); } $ Scope.updateItem = function () {console.log ('$ scope.items was', $ scope.items); Var id = prompt ("enter $ id to update"); Var someItem = itemsList $ GetRecord (ID); Var newField = sign (enter new value for 'newField'); SomeItem.newField = newField; ($ $ Scope.items is now '$ scope.items);}) ;; }
example
- See this job
- I created things that would get the same result as given above code Are there.
- li>
Hope that helps!
No comments:
Post a Comment