[英]$window.open still opening url inside phonegap app (angular)
我有以下HTML和angular.js代碼:
<span ng-if="club.club_brief != ''">
<a href="#" ng-click="openLink('{{club.club_brief}}')">Website</a>
</span>
在我的控制器中:
$scope.openLink = function(url) {
$window.open(url, '_system');
}
編輯:閱讀了一些答案,我也嘗試過
$window.open(url, '_system');
但是我遇到了同樣的問題,因為它仍然在不嘗試打開瀏覽器的情況下仍在應用程序中加載網站。
我希望這樣可以防止在phonegap應用程序中打開鏈接,但事實並非如此。 我希望它在新的瀏覽器中打開(或提供瀏覽器的選項)。 這是針對Android的。
我不確定這將直接起作用。 您可能需要通過phonegap調用此服務。
嘗試$window.open(url, '_blank');
您是否嘗試過使用_blank。 您當前的標簽可能是_system。
$scope.openLink = function(url) {
$window.open(url, '_blank');
}
您不能在ng-click
內使用{{}}
插值,如果這樣做,則會在控制台中出現$parser
錯誤。
標記
<span ng-if="club.club_brief != ''">
<a href="#" ng-click="openLink(club.club_brief)">Website</a>
</span>
其他人認為您應該在從JavaScript標記打開標簽頁時使用_blank
。
$window.open(url, "_blank")
解決方法是使用
<a href="{{club.club_brief}}" target="_blank">Website</a>
附帶說明,使用ng-click
您只需編寫
<a href="#" ng-click="openLink(club.club_brief)">Website</a>
不需要{{ }}
或''
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.