In my app, I of course have a link to facebook and twitter. However what happens is that these links are opened within my app, and not loaded externally.
This is fine for the mobile website version, but natively as an app this is not desirable. How do I go about loading external web resources externally when installed as an app?
Are you using phonegap 3.x? Youâll want to install the InAppBrowser plugin, and add target="_system" to your links that you want opened externally. (or use $window.open(âurlâ, â_systemâ) if youâre doing it programmatically)
Installed inappbrowser plugin via cordova. Added _system to target and it doesnât work.
From what I read it should just work on a regular <a href="blah" target="_blank">, but then it goes to say a bunch of other shit that you need to do to get it working after it says you donât need to do anything extra.
Having a little trouble still, because ng-bind-html filters out the browse-to in itâs output. Do you know how to make sure ng-bind-html doesnât sanitize this property from its output?
I am trying to login the user by social login on my site I achieved this by your answer. But the problem is that i cant close the window once the user is successfully logedin. I tried to render javascript window.close() but its not working. Can you help me out.
@ftorre104 Easiest solution by far. I wrote a filter to convert links to this just in case anyone was needing to parse text that they may have gotten from an external source. It requires ngSanitize, though you can take out those sections if you trust the html.
myApp.filter('hrefToJS', function ($sce, $sanitize) {
return function (text) {
var regex = /href="([\S]+)"/g;
var newString = $sanitize(text).replace(regex, "onClick=\"window.open('$1', '_blank', 'location=yes')\"");
return $sce.trustAsHtml(newString);
}
});
I tried this solution but I got an issue.
My first parameter in window.open should be like : {{store.twitter}} (for example).
But this doesnât work because itâs recognise as a string.
You can use something like <a href="{{store.twitter}}" onclick="window.open(this.href, '_blank', 'location=yes');return false;">Twitter</a> href will be parsed by AngularJS.