anchor - Linking to external URL with different domain from within an angularJS partial -


all trying include anchor tag inside html of partial links external site. standard html, code be:

<a href="http://www.google.com" target="_blank">google</a> 

as simple is, cannot seem find working solution getting past angular intercepting route (or perhaps replacing anchor https://docs.angularjs.org/api/ng/directive/a directive unintentionally?).

i have scoured , rest of web , seen myriad of solutions dealing with: links within same domain, routing within spa, routing within page (ala $anchorscroll) none of these issue exactly.

i suspect may having using $sce angular n00b , not sure how use service. tried following in view controller:

$scope.trusturl = function(url) {     return $sce.trustasresourceurl(url); } 

with corresponding:

<a ng-href="{{ trusturl(item) }}">click me!</a> 

(as described here: binding external url in angularjs template)

but did not seem trick (i ended href="{{" in rendered page).

using plain vanilla anchor link this:

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

also failed trick (even though online advised standard href cause complete page reload in angular: angularjs - how can redirect full page load?).

i tried adding target=_self" attribute seemed have no effect either.

do need write custom directive described here?

conditionally add target="_blank" links angular js

this seems way complicated such simple action , feel missing obvious in n00bishness, @ least hope because process feeling onerous link url.

thanks in advance solutions, advice, refs or direction.

it turns out did in fact have anchor links in page bound event listener , being overridden. since code fundamental way page worked did not want mess it. instead bypassed using ng-click call new url follows:

html:

<a class="navlinkhcp" href="{{hcpurl}}" title="habitat conservation plan" target="_blank" ng-click="linkmodelfunc(hcpurl)">habitat conservation plan</a> 

controller:

$scope.hcpurl = 'http://eahcp.org/index.php/about_eahcp/covered_species';  $scope.linkmodelfunc = function (url){   console.log('link model function');   $window.open(url); } 

and voila! go. again kevinb cluing me in issue.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -