I want to update my DOM element everytime the value on the Firebase changes. I've seen that Angularfire
handles three-way data binding, but from what I understood it only works if you take elements from $firebaseArray
directly from the DOM.
What I have is an Element on the DOM (chart) that depends on some of the data on a $firebaseArray
, but my element gets the data from a function instead of directly from the $firebaseArray
. That means I have to do some pre-processing on the $firebaseArray
before my element can use it.
This is what I have:
<pie-chart ng-repeat="chart in myCtrl.charts"
data="chart.data"
options="chart.options"></pie-chart>
This is my controller:
function MyCtrl($firebaseArray) {
let myRef = new Firebase(refUrl);
let chartsFirebase = $firebaseArray(myRef);
let getCharts = function() {
let charts = [];
distanceGoals.$loaded().then(function() {
// push some things from chartsFirebase on the charts array
charts.push({
options: { ... },
data: [ ... ]
});
}
return charts;
}
this.charts = getCharts();
}
Turns out that in this way this.charts
is only updated one time, after modifications on the data in Firebase I have to refresh the browser.
- Has anyone an idea of what I could do to achieve this behavior?