rtrtrt

I get this, when" /> rtrtrt

I get this, when" /> rtrtrt

I get this, when"/>

How to allow external link in angularjs when using ng-bind-html

664 views Asked by At

Here is the rendered code

<div>dfdbfbdfbdfbdfbdfbfb gdfgfggtbrtb  
   <a href="www.github.com" target="_blank"> rtrtrt
   </a>
   <p></p>
</div>

I get this, when i click in the hyperlinked text

https://myapp.io/www.github.com
3

There are 3 answers

0
Junaid Sarwar On BEST ANSWER

Remember to use HTTP protocol with external links, if you don't use HTTP before the link, it will be considered as local resource link. In your above mentioned code you should use

<a href="http://www.github.com">Github</a>

Instead of

<a href="www.github.com">Github</a>

4
namelivia On

Try <a href="https://www.github.com" target="_blank"> the link destination you pasted is relative to the domain you are in.

0
NDalvise On

The easy way is to use $window in the controller and a ng-click in the view.
In the view:

<a ng-click="myFunctionToGoAwayFromAngularJS()">click me</a>

And in the controller:

$scope.myFunctionToGoAwayFromAngularJS = function () { $window.open("https://www.github.com"); };

Obviously you need to inject $window in your controller. This way you can assign ng-click in whatever tag you want, not only to anchor tags.