表达式值仅在数据加载时更新,然后不再更改。
虽然滑块的值已更改并触发filterPrices
功能
我看到控制台上的值已更改,但视图仍保持相同的值。
它会在加载时以及滑块的值发生变化时触发。
$scope.filterPrices = function(chart){
# select the cheapest flight here
console.log(target_flight.y)
chart.target_flight = target_flight;
}
触发控制器功能filterPrices
link:function(scope, element, attr, ctrl){
$(element).ionRangeSlider({
onChange: function(slider) {
var _this = this;
updateFlighSeries(slider, scope[_this.chartConfig].series)
angular.forEach(scope.chart_names, function(chart_cfg_name){
setTimeout(function () {
scope.$apply(function () {
scope.filterPrices(scope[chart_cfg_name])
});
}, 2000);
}, scope)
scope.$apply();
}
});
<li class="col-4 color7">
<span>> departure flight</span>
{{ departChartConfig.target_flight.y }}
</li>
<li class="col-4 color7">
<span>> return flight</span>
{{ returnChartConfig.target_flight.y }}
</li>
onChange: function(slider) {
var _this = this;
updateFlighSeries(slider, scope[_this.chartConfig].series)
angular.forEach(scope.chart_names, function(chart_cfg_name){
$timeout(function () {
// scope.$apply(function () {
scope.filterPrices(scope[chart_cfg_name])
// });
}, 200);
}, scope)
}