I have the following HTML and angular.js code:
<span ng-if="club.club_brief != ''">
<a href="#" ng-click="openLink('{{club.club_brief}}')">Website</a>
</span>
In my controller:
$scope.openLink = function(url) {
$window.open(url, '_system');
}
EDIT: Having read some answers I also tried
$window.open(url, '_system');
but I'm getting the same problem in that it's still loading the site within the app without trying to open a browser.
I was hoping that would prevent the link from being open inside the phonegap app but it's not. I want it to open in a new browser (or give the option of the browser). This is for Android.
I am not sure this will work directly. you probably need to call the service for this through phonegap.
尝试$window.open(url, '_blank');
Have you tried using _blank. It's possible your current tab is _system.
$scope.openLink = function(url) {
$window.open(url, '_blank');
}
You could not use {{}}
interpolation inside ng-click
, if you do it then you will get an $parser
error in console.
Markup
<span ng-if="club.club_brief != ''">
<a href="#" ng-click="openLink(club.club_brief)">Website</a>
</span>
Other think you should use _blank
while opening tab from the JavaScript tag.
$window.open(url, "_blank")
A workaround could be to use
<a href="{{club.club_brief}}" target="_blank">Website</a>
As a sidenote, when using ng-click
you can just write
<a href="#" ng-click="openLink(club.club_brief)">Website</a>
No need for {{ }}
or ''
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.