firebasefirebase-realtime-databasepolymerpolymer-1.0polymerfire

this.$.<id> syntax giving me error when retrieving data from firebase with polymer


I am using polymer and firebase, and I wanted to retrieve data from the database once. To achieve this, I did something like this inside my custom element:

 ready: function(){
    this.$.query.ref.once('value').then(function(snapshot) {
      this.$spinner.removeAttribute('active');
    });
  }

And I have

      <paper-spinner id="spinner" active></paper-spinner>

This inside my element

Now, this gives me the following error:

Uncaught (in promise) TypeError: Cannot read property 'spinner' of undefined

What am I doing wrong? Can I not use the this.$. syntax inside that function for some reason?


Solution

  • the line should be like this : this.$.spinner.removeAttribute('active');

    you are missing "dot" after the $ sign.