谷歌聚合物和firebase文件用javascript更改数据?

时间:2015-10-25 17:08:49

标签: javascript firebase polymer

我正在使用聚合物构建一个Web应用程序,我使用firebase作为数据库。我想建立一个用户邮件确认网站。 - >当网站打开时,应该更新一个简单的firebase节点。我的电子邮件确认:

<dom-module id="email-confirmation">
    <template>
      <firebase-document
        id="idd"
        location="[[location]]"
        data="{{userToConfirm}}"
        on-data-changed="callMe">
      </firebase-document>

      <template is="dom-if" if="{{isConfirmed(userToConfirm)}}">
        <p>It worked!</p>
      </template>
    </template>
  <script src="./email-confirmation.js"></script>
</dom-module>

和我的电子邮件确认.js:

class EmailConfirmation {
  beforeRegister() {
    this.is = 'email-confirmation';
    this.properties = {
      /**
       * Defines the email, that will be confirmed.
       */
      email: {
        type: String
      }
    };
    this.observers = [
      // Note that this function  will not fire until *all* parameters
      // given have been set to something other than `undefined`
      'attributesReady(email)'
    ];
  }

  attributesReady(email) {
    this.location = document.createElement('iron-meta').byKey('firebaseLocation') + 'users/' + email;
  }

  isConfirmed(bla) {
    this.userToConfirm.confirmed = true;
    bla.confirmed = true;
    return true;
  }

  callMe(event, values) {
    this.userToConfirm.confirmed = true;
    event.detail.value.confirmed = true;
    event.currentTarget.data.confirmed = true;
    this.$.idd.data = true;
    values.value.confirmed = true;
  }
}

如您所见,我尝试在此处使用不同的方法。但这些调用都没有实际更新我的firebase节点!我该如何使用javascript更新我的节点?

我还认为通知firebase-document可能存在问题,即值已更改。我试图解雇一个事件,但它们似乎没有达到firebase-document。 (可能是因为这些事件没有向孩子开除)

亲切的问候 马克

1 个答案:

答案 0 :(得分:1)

尝试使用query属性 this.$.idd.query.set('confirmed', true);