I am trying to dynamically assign an attribute to an iron-ajax pattern, but it resolves to undefined.
<dom-module id="products-service"> <style> :host { display: none; } </style> <template> <iron-ajax id="productsajax" auto url="http://localhost:3003/api/taxons/products" params='{"token":"my-token"}' method='GET' on-response='productsLoaded' handleAs='json'> </iron-ajax> </template> </dom-module> <script> (function() { Polymer({ is: 'products-service', properties: { categoryid: { type: String, notify: true, reflectToAttribute: true } }, </script>
As a result, the URL looks like this:
`http:`
The dom-module categoryid property is not undefined , since I can see the correct value of the property reflected in the attributes, which means that this is due to how to assign it to the attribute. I also tried this on created and attached callbacks and still didn't work.
Edit: categoryid is passed to the module when it is created as follows:
<products-service products="{{products}}" categoryid="{{categoryid}}"></products-service>
As you can see here, the categoryid passed to the service already matters. (The names of the elements in the image may differ slightly. I have abbreviated them to make the question less detailed.)

category-products-list where the service is called looks like
<dom-module id="category-products-list"> <template> <category-products-service products="{{products}}" categoryid="{{categoryid}}"></category-products-service> <div> <template is="dom-repeat" items="{{products}}"> <product-card on-cart-tap="handleCart" product="{{item}}"> <img width="100" height="100"> <h3>{{item.name}}</h3> <h4>{{item.display_price}}</h4> </product-card> </template> </div> </template> </dom-module> <script> (function() { Polymer({ is: 'category-products-list', properties: { categoryid: { type: String, notify: true, reflectToAttribute: true } }, ready: function() { </script>
Optimus pette
source share