4
我遇到问题,即我的角度图在工厂广播中更新时不显示数据。我根据用户的输入,这可能更改设置标签和数据,如这样,:从观察者填充角度图 - 奇怪行为
// Listener function in controller, receives data from factory
$scope.$on("New Data", function(event, data, ID) {
processTripData(data, ID).then(function(result) {
setTypeDistributionBar(result).then(function(r) {
buildTypeDistributionBar(r.data, r.labels);
})
})
})
var buildTypeDistributionBar = function(data, labels) {
$scope.distributionLabels = labels;
$scope.distributionData = [data];
}
的问题是,这只是buildTypeDistributionBar
第二个电话后更新图表。因此,此图表始终是1查询背后的用户放入什么。
问:为什么只有在第二次调用该图表后才显示图表?我怎样才能实现它立即更新?
更新:我创建了一个fiddle来演示这一点,它不显示像我一样的行为,但类似。