Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

javascript - Polymer + Firebase (Polymerfire): Cannot read property 'push' of undefined': 'this.$.query.ref.push(...)'

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...