微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 全局设置angular.js url root

我有一个角度的应用程序,托管在我的大学服务器.

因为应用程序不在域根目录(网址被构造如下: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" />

原文地址:https://www.jb51.cc/js/155234.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐