Polymer refresh the property's value which is calculated by a method Polymer refresh the property's value which is calculated by a method angularjs angularjs

Polymer refresh the property's value which is calculated by a method


I am not familiar with polymer and if there are possibilties to delay the execution of the polymer code or if there a digest cycles one could work with like in AngularJS.

But I would guess you could avoid this kind of race condition with a simple ng-if= in conjunction with <ng-include> on AngularJS side - as it does not add the elements to the DOM, thus avoid any kind of interaction with polymer until it is included.

So e.g.:

<figure ng-if="dataContainer.getSomeData">    <ng-include src="'template.html'"></figure>

And within template.html your (unmodified) code:

<template is="dom-bind" angupoly="{dataContainer:'dataContainer'}">    <menu-list for="places" data="{{dataContainer.getSomeData()}}"></template>

I would be happy if this helps you - but as I said it is just a guess and I don't know much about polymer and how it interacts with the DOM.


The error that you are seeing is not caused by dataContainer being undefined, but the function that you call on it. Polymer does not support this type of function calls in data-binding. From the docs:

Data binding binds a property or sub-property of a custom element (the host element) to a property or attribute of an element in its local DOM (the child or target element).

You are calling a function on a property, which does not work. If you want to call a function, you could to this with computed bindings.

<menu-list for="places" data="{{getData(dataContainer.*)}}">

However, this assumes that your menu-list is placed in some parent Polymer element and I'm not sure if this is the case here as you use a dom-bind. However, if you do have a parent element you could then add the computed function there.

Polymer({    is: 'parent-element',    properties: {dataContainer: ....},    getData: function() {        return dataContainer.getSomeData();    }});

getData will be called anytime dataContainer or its sub-properties change.