When working with my Angular app, I have set <base href="/foo/bar/">
and enabled html5 mode using
$locationProvider.html5Mode(true);
Now, I want to generate a list that looks like this:
<div ng-repeat="item in vm.items">
<a ng-href="{{item}}" target="_blank">{{item}}</a>
<a ng-href="{{item}}" download>{{item}}</a>
</div>
The items I have can be URLs such as:
['example1.com', 'www.example2.com', 'http://www.example3.com', 'https://www.example4.com'];
It currently works fine for example3
and example4
, but how can I resolve the following issues:
example1.com
- it gets redirected tohttp://localhost/foo/bar/example1.com
www.example2.com
- it gets redirected tohttp://localhost/foo/bar/www.example2.com
I am looking for the best way to force the usage of absolute URLs. It needs to work with both http
and https
, as well as include the download
attribute.