Thursday 17 December 2015

Phonegap - opening href links in a browser

Convert text from href links into ng-click.

//input: <a href="xxx">
        //output: <a ng-click="GotoLink('xxx')">
        function convert2ngclick(str) {          
            var res = str.replace(/<a href=\"(.+?)\">/g, '<a ng-click="GotoLink(\'$1\')">');
            return res;
        }

2 comments:

  1. Awesome. Was searching for this from many days.. Thanks a lot!!

    ReplyDelete
  2. Im using the below code. All dynamic links inside content opening fine(opening in in-app browser). But twitter links not opening in in-app-browser. Twitter links navigating to file:///android_asset/www/index.html. Any help???

    https://pastebin.com/ZWHmdXuP

    ReplyDelete