2017-04-26 12 views
1

私は、動作にobserverを打ち切ったときだけ、変化は検出されないことを発見しました。オブザーバーは行動に使用できませんか?オブザーバは動作しませんか?

<iron-ajax 
     auto="[[activated]]" 
     url="[[HOST]][[LISTINGS]]/[[listingNumber]]" 
     handle-as="json" 
     verbose="true" 
     with-credentials="true" 
     on-error="_error" 
     loading="{{loading}}" 
     last-error="{{apiError}}" 
     last-response="{{listing}}"></iron-ajax> 

    </template> 

    <script> 
    Polymer({ 
     is: 'single-listing', 
     behaviors: [ApiConstants, IronAjaxHelpers], 

<script> 
    IronAjaxHelpers = { 
    listingNumber: { 
     type: Number, 
     value: 0, 
     notify: true 
    }, 
    activated: { 
     type: Boolean, 
     value: false, 
     observer: 'setListingNumber' 
    }, 
    setListingNumber: function(newValue, oldValue) { 
     console.log(newValue); 
     //this.listingNumber = id; 
     if (newValue === true) { 
     this.listingNumber = app.listingNumber; 
     } 
    } 
    }; 
</script> 

答えて

1

あなたの行動のプロパティがpropertiesフィールド内に定義されなければならないが、それは行動オブジェクトのトップレベルで、現在です。

あなたはこのような振る舞い内部プロパティを宣言する必要があります。

IronAjaxHelpers = { 
    properties: { 
    /** PROPERTIES GO HERE **/ 

    listingNumber: { 
     type: Number, 
     value: 0, 
     notify: true 
    }, 
    activated: { 
     type: Boolean, 
     value: false, 
     observer: "setListingNumber" 
    } 
    }, 

    setListingNumber: function(newValue, oldValue) { 
    console.log(newValue); 
    } 
}; 

codepen

関連する問題