简体   繁体   English

在Angular JS中将数据绑定到作用域之前淡出微调器

[英]Fade out spinner right before data are binded to scope in Angular JS

The following code will fade out the spinner after it actually bind data from Firebase. 在实际绑定Firebase的数据之后,以下代码将使微调器消失。

myFactory.$bindTo($scope, 'fact').then(function() {
  $('#spinner').fadeOut(1000);
});

But how can I fade it out half a second before the data gets binded? 但是,如何在绑定数据之前半秒将其淡出?

Here's a solution which would delay the binding by half a second once the data is loaded. 这是一个解决方案,一旦加载数据,绑定就会延迟半秒。

myFactory.$loaded().then(function() {
  $('#spinner').fadeOut(1000);
  $timeout(function() {
    myFactory.$bindTo($scope, 'fact');
  }, 500);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM