Ionic external link open in app browser


Ionic external link open in app browser : When we are working with ionic we often need to open external links in our app browser. Fo this you need to install ngCordova. Make sure you have installed this plugin Otherwise it will not work. Here we are going to explain the external example in ionic.


Ionic external link open in app browser

First Confirm You Have installed the following plugins and added the following code –

  • ngCordova – Install ngCordova if not installed check here the steps to install http://ngcordova.com/docs/install/
  • Make Sure You Have Added the ngCordova in your module as –
     angular.module('todo', ['ionic','ngCordova'])

    .
    For this you need ngCordova installed.

  • Now Add the following js to open links in appBrowser using the cordova-
    <script>
               document.onclick = function (e) {
            e = e ||  window.event;
            var element = e.target || e.srcElement;
            if (element.tagName == 'A') {
                window.open(element.href, "_blank", "location=no");
                return false;
            }
        };
         </script>

    Add the above code in the head of your index.html file.

Ionic external link open in app browser not working.

I am sure if you have installed cordova and added the above code and module it will work.


Advertisements

Add Comment

📖 Read More