I want open a web page in my app, I know I should use ngCordova InAppBrowser plugin, but how can I open the webpage in $ionicModal ? like twitter, facebook mobile apps and ...
I have this button :
<button class="button button-block button-assertive" ng-click="doPay()">Pay</button>
and in doPay() I have :
$scope.doPay = function(){
window.open(url, '_system', 'location=no');
};
but this code use external app (Safari), I want open in my application.
To open the web inside your app you have to use the _blank option instead of _system
$scope.doPay = function(){
window.open(url, '_blank', 'location=no');
};
Edit: window.open no longer works as default, to re enable it you’ll need to add this code
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}
Or use cordova.InAppBrowser.open instead of window.open
Related
I am working on mobile app using:
Ionic 2.1.4
Cordova 6.4.0
Angular 1.5.3
I've one view with external url using InAppBrowser plugin and I have a link in this website should redirect to certain view in my app
this issue is $location.url() not redirecting and not working at all, but when I tested the event I found it trigger normally.
here is my full code
angular.module('yogipass').controller('iframe',function ($location) {
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log('here');
var ref=cordova.InAppBrowser.open('http://192.168.42.218/index.html', '_blank', 'location=no');
ref.addEventListener('loadstart', function(event) {
if (event.url.match("mobile/login")) {
console.log('worked!') // this logged normally
$location.url('/login');
ref.close();
}
});
}
])
You have to run digest cycle manually as you are changing location path from asynchronous event which is outside angular context.
Do wrap you code in $timeout function, which will fire up digest cycle. Apparently that will help to update location.
$timeout(function(){
$location.url('/login');
})
I am developing a mobile app using angular js, cordova , ionic and using intel xdk to build. Here my problem is whenever i click the back button in mobile device, app get closed itself instead of redirecting to previous page.Is that ionic problem?
Also tried addEventListener
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown() {
alert();
$location.path('/sandhyavMor');
}
Here, still the app getting closed after firing the alert. Also i am using intel xdk media plugin.
so what may be the problem.
Try using this code.Use it in app.js
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function ($ionicPlatform,$state,$log, $rootScope,$ionicHistory) {
$ionicPlatform.registerBackButtonAction(function (e) {
if ($ionicHistory.backView()) {
$ionicHistory.goBack();
} else {
$state.go($rootScope.previousState);
}
e.preventDefault();
return false;
}, 101);
});
Are you sure there is a previous view to go back to? Are there tabs in your app?
I need to launch to launch an external url / website in Onsen Ui without leaving the app. I can use an iframe I guess between the ons-page tags where I need it but not very reliable perhaps.
Its my first Onsen Ui project.
Jimmy
Simply using the method below on OnsenUI
Link
will destroy and replace the whole app (web view) with external HTML resources.
Solution: so you may need the helps of cordova-plugin-inappbrowser plugin.
In your case,
launch an external url / website in Onsen Ui without leaving the app,
you need "_self" or "_blank" ("_blank" is used for example codes below)
// opts is optional depend on your requirements
var opts = 'location=yes';
var ref = cordova.InAppBrowser.open('http://www.example.com', '_blank', opts);
or you can use ngCordova's $cordovaInAppBrowser
angular.module('app')
.controller('ctrl', ['$cordovaInAppBrowser', function($cordovaInAppBrowser) {
var opts = {location: 'yes'};
$cordovaInAppBrowser.open('http://www.example.com', '_blank', opts);
}]);
i faced the same problem and i use this method its not fancy but it workes for me
<a class="name" href="#" onclick="window.open('https://www.youtube.com/watch?v=_OOWhuC_9Lw', '_system', 'location=yes'); return false;">
Watch
</a>
I have a project with Django and Angular.
I have a page located at http://localhost:8000/install/#/, that is part of the install app. There I have a button which POST a form, then I want the function in my controller to redirect to http://localhost:8000/, my index page.
$http.post('install/send_install_form/', installation) //installation is a dictionary
.then(function(data){
alert('You will be redirected')
setTimeout(function(){
// REDIRECTION TO THE INDEX..?
},
4000
)
},
function(data){
alert("Error")
})
How do we link between and out of apps with Django-Angular?
Thank you!
Redirect within the angularJS app:
scope.$apply(function() {
$location.path("/route");
});
Redirect outside the angularJS app:
window.location.replace('http://google.ca/');
Im using PhoneGap to build an app. In this app I'want to create a geo link. PhoneGap does open a map with the right location on it, but the map is not Google Maps or Apple maps. Instead it opens a weird looking map.
I'm using AngularJS as a Framework
Right now I'm using this:
View on Google Maps
Is there a way that the app will open up the Google Maps downloaded from the Play Store?
Thanks!
Try to add the following to config.xml
<access origin="geo:*" launch-external="yes"/>
And try this:
Create a custom function in JS and use it to open default Maps App on the device
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
openNativeAppWindow: function(data) {
window.open(data, '_system');
}
};
The place where you are invoking Maps links then pass on your custom url with data and let it open the native browser window which in turn will push the native Maps App to handle the special urls.
Few example:
<input type="button" onClick="app.openNativeAppWindow('http://google.com')" value="Open Google"/>
<br><br><a onClick="app.openNativeAppWindow('geo://0,0?q=dallas')" data-rel="external">google maps</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=Bacau')">Geolocation Test</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=34.99,-106.61(Treasure)')">longitude & latitude with a string label</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA')">street address Test</a>