External Links (facebook/twitter) to load OUTSIDE of app?

Yeah some of the documentation I’ve found is contradictory.

First of all: http://phonegap.com/2012/03/19/phonegap-cordova-and-what’s-in-a-name/

Secondly
(Using the InAppBrowser plugin) I created this directive to handle my “open up in the browser and not in my app” links:

.directive('browseTo', function ($ionicGesture) {
 return {
  restrict: 'A',
  link: function ($scope, $element, $attrs) {
   var handleTap = function (e) {
    // todo: capture Google Analytics here
    var inAppBrowser = window.open(encodeURI($attrs.browseTo), '_system');
   };
   var tapGesture = $ionicGesture.on('tap', handleTap, $element);
   $scope.$on('$destroy', function () {
    // Clean up - unbind drag gesture handler
    $ionicGesture.off(tapGesture, 'tap', handleTap);
   });
  }
 }
});

Usage:
<button browse-to="https://www.google.com">Open Google</button>

Hope it helps!

11 Likes