我有一个角度的应用程序,托管在我的大学服务器.
因为应用程序不在域根目录(网址被构造如下:university.domain /〜< student_id>),所有链接和图像srcs都被破坏(有角度假定它位于域根目录中).
我的问题是:如何覆盖角基址,所以我仍然可以使用像ng-href,ng-src等的好东西?
解决方法
引用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.
更多这里on the official documentation.
例
<base href="university.domain/~12345678" />