Angular.js - 以局部视图prevent直接访问 [英] Angular.js - Prevent Direct Access to Partial Views

查看:166
本文介绍了Angular.js - 以局部视图prevent直接访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户不能够在浏览器中访问其URL时,直接查看谐音。例如,如果我的局部视图位于:

I want the users to not be able to view the partials directly when accessing their url in the browser. For example if my partial view is located in:

/partials/myPartial.html

我还可以直接访问它,看到了奇怪的标记。有没有一种方法,以prevent它并只能通过角部分的看法?谢谢你。

I can still directly access it and see the odd markup. Is there a way to prevent it and make the partial views only available through angular? Thanks.

推荐答案

好了,不是真的。

目前每天一个浏览器需要能够访问部分下载它的末尾。如果浏览器能做到这一点您的用户将能够这样做很好。你可能最终使它有点他们很难通过配置您的服务器直接打谐音(例如,以使其只响应具有一定的头,要求和配置 $ HTTP 来发送每个XHR请求这个头)。

At the end of a day a browser needs to be able to access a partial to download it. If a browser can do this your users will be able to do so as well. You might eventually make it a bit harder for them to hit partials directly (for example to by configuring your server so it only responds to request with a certain header and configure $http to send this header on each XHR request).

另一种可能性是,以pre-负荷谐音前期所描述的这里而不是通过揭露他们HTTP在所有的(实际上这是生产部署一个很好的做法反正)。

The other possibility is to pre-load partials up-front as described here and not expose them via HTTP at all (actually this is a good practice for production deployments anyway).

否则很难提出一个有意义的解决方案,不知道什么是你正在试图解决的确切的问题(从功能上来说)。

Otherwise it is hard to propose a meaningful solution without knowing what is the exact problem (functionally speaking) that you are trying to solve.

这篇关于Angular.js - 以局部视图prevent直接访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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