Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set angular.js url root globally

I have an angular app that is hosted at my university server.

Because the app is not in domain root (urls are constructed as follows: university.domain/~<student_id>) all links and image srcs are broken (angular assumes that it is located in domain root).

My question is: how can I override angular base url so I can still use goodies like ng-href, ng-src etc.?

like image 522
Nebril Avatar asked Dec 01 '13 09:12

Nebril


1 Answers

Quoting the AngularJS documentation:

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.

More here on the official documentation.

Example

<base href="university.domain/~12345678" />
like image 77
francisco.preller Avatar answered Oct 13 '22 07:10

francisco.preller