ng-include和ng-view不会同时加载 [英] ng-include and ng-view not loading at the same time

查看:108
本文介绍了ng-include和ng-view不会同时加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的应用程序的结构。很简单。页眉和页脚是非常小的文件。而首页上的ng-view更大。我注意到当我进入页面时。首先加载两个ng-include,然后显示ng-view并将页脚推到底部。页脚会闪烁约0.1秒,但颜色会有所不同。所以对我来说很清楚。

below is the structure of my app. very simple. header and footer are very small files. while the ng-view on homepage is much bigger. I noticed that when i enter the page. the two ng-include get loaded first, then the ng-view come up and footer get pushed to the bottom. the footer flashes for like 0.1 sec, but it's in a different color. so it is quite clear to me.

    <div ng-include='"app/core/templates/header.html"'></div>
    <div ng-view autoscroll="true"></div>
    <div ng-include='"app/core/templates/footer.html"'></div>

是否仍然可以让它们同时完成加载。并一起显示?还是让它更平滑?

Is there anyway to have them finish loading at the same time. and display all together? or anyway to make it more smooth?

推荐答案

在ng-cloak中,您可以显示其他div,直到加载完成
如果您要在主体中加载angular.js或模板编译得不够快,请使用ng-cloak指令,并在CSS中包括以下内容:

There is ng-cloak in angular you can show other div until loading finishes In cases where you are loading angular.js in the body or templates aren't compiled soon enough, use the ng-cloak directive and include the following in your CSS:

/* 
  Allow angular.js to be loaded in body, hiding cloaked elements until 
  templates compile.  The !important is important given that there may be 
  other selectors that are more specific or come later and might alter display.  
 */
[ng\:cloak], [ng-cloak], .ng-cloak {
  display: none !important;
}

这篇关于ng-include和ng-view不会同时加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆