I'm following a Polymer + Firebase tutorial video using the Polymer App Tool Kit (initiated with the polymer CLI).
When I try to push data to a Firebase collection, I get the following error:
Cannot read property 'push' of undefined'
Here's my code (firebase app is initiated in my-app.html with name "firebase-app"):
<dom-module id="add-model">
<!-- Defines the element's style and local DOM -->
<template>
<firebase-auth user="{{user}}" app-name="firebase-app"></firebase-auth>
<firebase-query
app-name="firebase-app"
id="query"
path="/users/[[user.uid]]/models"
data="{{model}}">
</firebase-query>
<paper-input id="modelName" label="Model Name" "></paper-input>
<paper-button class="create" id="create" on-tap="create" raised>Create</paper-button>
</template>
<!-- Creates the element's prototype and registers it -->
<script>
Polymer({
is: 'add-model',
properties: {
data: {
type: Object
}
},
create: function() {
this.$.query.ref.push({
name: this.$.modelName.value
});
}
});
</script>
</dom-module>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…