Hello,
I am using Ionic with the same code for a mobile device and a single-page web app. I’d like to open external content using target="_blank"
in the browser to avoid javascript pop-up issues, but use $cordovaInAppBrowser
plugin on mobile devices.
Are there any bad side-effects to using this code? Or is there a better way to do this?
<a ng-href="{{anchorClick(url)}}"
ng-click="anchorClick(url,$event)"
target="_blank">
[markup]
</a>
anchorClick: (url,ev)->
return if !url
# use HTML target="_blank" for browsers
return url if ionic.Platform.isWebView()==false
# $cordovaInAppBrowser.open for devices
return 'javacript:void(0)' if !ev
ev.stopImmediatePropagation()
options = {
location: 'yes'
clearcache: 'yes'
toolbar: 'no'
}
$cordovaInAppBrowser.open(url, '_system', options)
return false