如何决定何时使用ngView或ngInclude? [英] How to decide when to use ngView or ngInclude?

查看:127
本文介绍了如何决定何时使用ngView或ngInclude?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想了解在AngularJS使用ngView和ngInclude办法准确的区别。当它被正确使用一个比其他?谢谢你。

Just trying to understand the exact difference in approaches of using ngView and ngInclude in AngularJS. When would is it correct to use one over the other? Thanks.

推荐答案

ngView与路由一起工作,并且主要以角SPA是必不可少的。它通常用于包括你的网站的主要内容,以改变每次用户点击一个链接时页眉和页脚间位。它具有路由集成意味着改变ngView内容的变化,控制器太(取决于您的配置)。

ngView works together with routing, and is mostly essential to an angular SPA. It's normally used to include the main content of your site, the bit in between the header and footer that changes every time a user clicks a link. Its integration with routing means changing the ngView content changes the controller too (depending on your configuration).

ngInclude是一个通用的包括,你甚至可能不会需要它。你有时会使用它的一个视图中,以避免重复自己,在几个视图需要包括在同一code中的情况。

ngInclude is a general purpose include, you may not even need it. You'd sometimes use it inside a view to avoid repeating yourself, in the cases where several views need the same code included.

这篇关于如何决定何时使用ngView或ngInclude?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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