但是在每次超时时,UI都会闪烁(短时间内为空模型).在新数据到达后如何更新模型(和视图)以避免这种闪烁效应?
这是我当前的控制器(从step_11(Angular.js教程)略微修改):
function MyPollingCtrl($scope, $routeParams, $timeout, Model) {
(function tick() {
$scope.line = Model.get({
modelId : $routeParams.modelId
}, function(model) {
$timeout(tick, 2000);
});
})();
}
Run Code Online (Sandbox Code Playgroud)
//编辑:我正在使用当前稳定的Angular.js 1.0.6