javascript – 全局设置angular.js url root

前端之家收集整理的这篇文章主要介绍了javascript – 全局设置angular.js url root前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个角度的应用程序,托管在我的大学服务器.

因为应用程序不在域根目录(网址被构造如下:university.domain /〜< student_id>),所有链接和图像srcs都被破坏(有角度假定它位于域根目录中).@H_502_3@

我的问题是:如何覆盖角基址,所以我仍然可以使用像ng-href,ng-src等的好东西?@H_502_3@

解决方法

引用AngularJS文档:

Relative links

Be sure to check all relative links,images,scripts etc. You must
either specify the url base in the head of your main html file
(<base href="/my-base">) or you must use absolute urls
(starting with /) everywhere because relative urls will be resolved to
absolute urls using the initial absolute url of the document,which is
often different from the root of the application.@H_502_3@

更多这里on the official documentation.@H_502_3@

例@H_502_3@

<base href="university.domain/~12345678" />

猜你在找的JavaScript相关文章