简体   繁体   English

除了ng-view页面加载

[英]other than ng-view page loading

I am using a master page having navigation and ng-view on it, partial pages loading successfully under ng-view and with navigation of master page , but I require to load some isolated page like login.html page but not under ng-view and without master page content during route. 我正在使用具有导航和ng-view的母版页,在ng-view和母版页的导航下成功加载了部分页面,但是我需要加载一些独立的页面,例如login.html页面,但在ng-view和在路由过程中没有母版页内容。

I am new on angular and not sure how to do this, login page loaded every time under ng-view. 我是angular的新手,不确定如何执行此操作,每次在ng-view下加载登录页面。

Please suggest me any way to do this. 请建议我采取任何方式。

Thanks in advanced. 提前致谢。

ng-include is your friend. ng-include是您的朋友。 see doc 见文件

here is simple way, but you should go to doc and see that there are extra options as to what can be done onload and if you want to autoscroll or do some kind of animation. 这是一种简单的方法,但是您应该转到doc上,看看在加载时可以执行的操作以及要自动滚动或进行某种动画处理方面还有其他选择。

<div ng-include="'somefile.html'">
</div>

The one extra note is that ng-include is given an expression so if you have a static reference you need the extra quotes. 需要特别注意的是ng-include是一个表达式,因此,如果您有静态引用,则需要使用额外的引号。

One of the great things about Angular is it is very flexible. Angular的一大优点是它非常灵活。 Ultimately it will depend on your app and how you work. 最终,这将取决于您的应用程序以及您的工作方式。 I'm not exactly certain what you are trying to accomplish but, it sounds like a job for the ngInclude directive as Dan mentioned . 我不确定您要完成什么,但这听起来像Dan提到ngInclude指令的工作。

You mention a login.html that excludes navigational and other main page content. 您提到的login.html排除了导航和其他主页内容。 Using a modal may be a viable alternative interface decision. 使用模式可能是可行的替代接口决策。

If you have everything built and you only want to hide part of the DOM and be done with it then, nghide or ngShow may be the quickest solution. 如果您已构建了所有内容,并且只想隐藏DOM的一部分并进行处理,那么nghidengShow可能是最快的解决方案。

If there is a lot of stuff on your index.html you may want to separate those things into partials other than the ones connected directly to your routes, and use ng-include="'path/to/partial.html'" to include them. 如果index.html上包含很多内容,则可能需要将这些内容分成与直接连接到路由的部分不同的部分,并使用ng-include="'path/to/partial.html'"包括他们。 (The "''" are intentional as it likes a string.) Read the docs and experiment with the plunkr . (“”“是有意的,因为它喜欢一个字符串。)阅读文档并尝试使用plunkr You can do a lot of cool things with ngInclude, especially if you pay attention to its context. 使用ngInclude可以做很多很酷的事情,特别是如果您注意它的上下文。

If you combine the ngInclude directive with ng-switch-when, you could put together something like: 如果将ngInclude指令与ng-switch-when结合使用,则可以将以下内容放在一起:

<div ng-switch="routeAction">
    <div ng-switch-when="extpage" ng-include="'extraneous.content.html'"></div>
    <div ng-switch-when="login" ng-include="'login.partial.html'"></div>
    <div ng-switch-default ng-include="'default.tpl.html'"></div>
</div>

Where routeAction is tied to your controler which, is tied to your $route or $location.. depending on how you have things set up. routeAction绑定到您的控制器上,该控件绑定到$ route或$ location ..上,具体取决于您的设置方式。

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

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