I am developing an hybrid mobile app in ionic and cordova. In this app I am using ngCordova InAppBrowse for load a html page into app.
Controller Code:
module.controller('MyCtrl', function($cordovaInAppBrowser) {
$scope.name="Rakesh";
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'no'
};
$cordovaInAppBrowser.open('mypage.html', '_blank', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
$rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event){
});
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
});
$rootScope.$on('$cordovaInAppBrowser:loaderror', function(e, event){
});
$rootScope.$on('$cordovaInAppBrowser:exit', function(e, event){
});
});
HTML Page (mypage.html)
<!DOCTYPE html>
<html>
<head>
<title>InAppBrowser - Test Page</title>
</head>
<body>
<form name="sendParam" method="post" action="https://www.example.com/payment">
<input type="text" id="name" name="name" value="" />
<input type="submit" value="enter">
</form >
</body>
</html>
What I Want?
I want to set or pass MyCtrl's $scope.name
value to mypage.html name text field
.
You Can not pass values to the controller to inAppBrowser using the $scope, inAppBrowser use to open the external web page to your mobile application.
If you want to pass value from ionic application to external page you must be pass the value using URL like http://html.net/page.php?paramOne=1254¶mTwo=ABC and you can get that value using $_GET['paramOne'] in PHP or else other server side language.
OR else You can get that value using javascript using below link Get url parameter jquery Or How to Get Query String Values In js
Hope i help you :)