I would suggest using the basic HTML tag in the head and encode all the paths regarding this. For example, in ASP.NET you can get a link to the application database, which may or may not be the root path for the site, so it’s useful to use the base tag. Bonus: it works for all other assets.
You can have a base path as follows:
<base href="/application_root/" />
... and then links like "foo / bar.html" will actually be / application _root / foo / bar.html.
Another approach that I like to use is to put named links in the header. I will often have the root of the API in one place and the root of the directive template somewhere else. I will add the following tags first:
<link id="linkApiRoot" href="/application_root/api/"/> <link id="linkTemplateRoot" href="/application_root/Content/Templates/"/>
... and then use $ provision in the module to get the href link and set it to services and directives as follows:
angular.module("app.services", []) .config(["$provide", function ($provide) { $provide.value("apiRoot", $("#linkApiRoot").attr("href")); }]);
... and then add it to a service like this:
angular.module("app.services").factory("myAdminSvc", ["apiRoot", function (apiRoot) { var apiAdminRoot = apiRoot + "admin/"; ...
Just my opinion. Do the least difficult thing for your application.
Barnabas Kendall Jun 09 '13 at 19:39 2013-06-09 19:39
source share