Skip to content

$bindAsArray don't update binded data dynamically #19

Closed
@monocles

Description

@monocles

I'm trying to bind a child node dynamically after the event changes.

...
var db = firebaseApp.database().ref('data/')

new Vue({
  el: '#app',
  data: {
    current: 'first',
    currentNode: []
  },
  firebase: {
    myArray: db
  },
  ready() {
    this.$bindAsArray('currentNode', db.child(this.current))
  },
  watch: {
    'curent': function(node) {
      console.log(node)
      this.$bindAsArray('currentNode', db.child(this.current))
    }
  },
  methods: {
    pushToNode() {
        this.$firebaseRefs.currentNode.push({
          hello: 'hello',
          world: 'world'
        })
      }
  }
})

and I expect to receive data at the output on binded array like this:
<pre>{{ currentNode | json }}</pre>

I have made 2 fiddle examples
First with $bindAsArray which does not update the state after the event triggering.
https://jsfiddle.net/tpq0x7zu/1/

And second one with $bindAsObject which updates the data after the child node changes.
https://jsfiddle.net/f95a1zwx/5/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions