1

I have a basic CRUD application written using the MEAN stack. In this I have an 'issues' model of which a number of properties are stored, including an external url which a user inputs.

I am trying to display this url so when the user clicks on it they are redirected to an external page (i.e. new tab in the browser). I am using Angular for this part.

With my current code I am always opening a new tab with the following url (http://localhost:3000/www.google.com). Taking the Google homepage as an external url example stored in the database.

My current code looks something like this.

view-issue.client.view.html

<a ng-href="{{ trustUrl(issue.sourceUrl) }}">Click me!</a>

issues.client.controller.js

$scope.trustUrl = function(url) {
    return $sce.trustAsResourceUrl(url);
};

I have also tried this solution already posted with the same result (Linking to external URL with different domain from within an angularJS partial).

Thank you for any help you can provide!

Community
  • 1
  • 1
rtkilian
  • 11
  • 1
  • WHat is the problem? – charlietfl Jul 16 '15 at 04:24
  • When the link is clicked my browser redirects to a url which looks something like: (http://localhost:3000/www.google.com). Instead of just being (www.google.com). – rtkilian Jul 16 '15 at 06:01
  • Sounds like you are missing the protocol in the url's. Without seeing the `//` browser will treat it as relative path. Need to check for `http[s]://` – charlietfl Jul 16 '15 at 12:25

0 Answers0