Angular在加载其他视图之前不显示视图

时间:2015-01-12 08:35:05

标签: javascript angularjs angular-ui-router

我有三种观点: 导航,主要内容,页脚。

我正在使用ui-router并且当页面被加载时导航和页脚被加载,但在主要内容中我有一个请求获取一些数据并且视图在导航和页脚之后延迟了一秒钟所以我坚持空中间内容到一秒钟。我怎么能这样做所有的观点会同时显示?

<div ng-include="'client/template/nav.tpl.html'"></div>
   <div class='main-wrapper'>
    <div ui-view='' class='view'></div>
   </div>
<div ng-include="'client/template/footer.tpl.html'"></div>

主要内容控制器:

function HomeController( $scope, promos ) {

    $scope.products = products.data; // this is come from the server directly, not ajax

  }

需要注意的是,请求主要内容的数据不是来自服务器请求及其全局的ajax请求。

1 个答案:

答案 0 :(得分:0)

在模板上使用ng-cloak

<div ng-cloak>
  <div ng-include="'client/template/nav.tpl.html'"></div>
   <div class='main-wrapper'>
     <div ui-view='' class='view'></div>
   </div>
  <div ng-include="'client/template/footer.tpl.html'"></div>
</div>
相关问题