如何从离子控制器传递值到inAppBrowser?

时间:2022-10-18 23:00:38

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.

我正在开发一种离子和科尔多瓦的混合移动应用程序。在这个应用程序中,我使用ngCordova InAppBrowse将html页面加载到应用程序中。

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)

HTML页面(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.

我想将MyCtrl的$ scope.name值设置或传递给mypage.html名称文本字段。

1 个解决方案

#1


2  

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.

您无法使用$ scope将值传递给控制器​​到inAppBrowser,inAppBrowser用于打开移动应用程序的外部网页。

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&paramTwo=ABC and you can get that value using $_GET['paramOne'] in PHP or else other server side language.

如果要将值从离子应用程序传递到外部页面,则必须使用http://html.net/page.php?paramOne=1254&paramTwo=ABC等URL传递值,并且可以使用$ _GET ['paramOne获取该值']在PHP或其他服务器端语言中。

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

或者您可以使用以下链接使用javascript获取该值获取URL参数jquery或如何获取js中的查询字符串值

Hope i help you :)

希望我帮助你:)

#1


2  

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.

您无法使用$ scope将值传递给控制器​​到inAppBrowser,inAppBrowser用于打开移动应用程序的外部网页。

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&paramTwo=ABC and you can get that value using $_GET['paramOne'] in PHP or else other server side language.

如果要将值从离子应用程序传递到外部页面,则必须使用http://html.net/page.php?paramOne=1254&paramTwo=ABC等URL传递值,并且可以使用$ _GET ['paramOne获取该值']在PHP或其他服务器端语言中。

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

或者您可以使用以下链接使用javascript获取该值获取URL参数jquery或如何获取js中的查询字符串值

Hope i help you :)

希望我帮助你:)