简体   繁体   English

$ window.open仍在phonegap应用程序中打开URL(角度)

[英]$window.open still opening url inside phonegap app (angular)

I have the following HTML and angular.js code: 我有以下HTML和angular.js代码:

<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. 我希望这样可以防止在phonegap应用程序中打开链接,但事实并非如此。 I want it to open in a new browser (or give the option of the browser). 我希望它在新的浏览器中打开(或提供浏览器的选项)。 This is for Android. 这是针对Android的。

I am not sure this will work directly. 我不确定这将直接起作用。 you probably need to call the service for this through phonegap. 您可能需要通过phonegap调用此服务。

尝试$window.open(url, '_blank');

Have you tried using _blank. 您是否尝试过使用_blank。 It's possible your current tab is _system. 您当前的标签可能是_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. 您不能在ng-click内使用{{}}插值,如果这样做,则会在控制台中出现$parser错误。

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. 其他人认为您应该在从JavaScript标记打开标签页时使用_blank

$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 附带说明,使用ng-click您只需编写

<a href="#" ng-click="openLink(club.club_brief)">Website</a>

No need for {{ }} or '' . 不需要{{ }}''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM