2014-12-04 44 views
1

Angular有没有办法通过https来检测应用程序是否被访问?我需要检测,以便构建正确的url并将其传递到$ http服务中,并且传递http将生成'the content must be served over HTTPS.'错误。检测应用程序是否通过SSL访问?

回答

4

可以使用$window服务来访问封装窗口对象:

if($window.location.protocol == "https") 
{ 
    // whatever 
} 
+0

哦,太好了,谢谢! – Zed 2014-12-04 15:29:09

+0

不客气! – mathieu 2014-12-04 15:45:15

相关问题