ionic-team / ng-cordova

OBSOLETE: Please move to Ionic Native https://github.com/ionic-team/ionic-native
https://github.com/ionic-team/ionic-native
MIT License
3.48k stars 1.05k forks source link

inAppBrowser events not being listened #1380

Open elbuki opened 7 years ago

elbuki commented 7 years ago

I'm having a hard time when I try to catch events from the browser in the application controller, none of the four events seems to be catched by the $on statement.

Here's my code:

www/js/app.js

angular.module('starter', ['ionic', 'starter.controllers',
                           'starter.services', 'ngCordova'])

// ...

.config(function($cordovaInAppBrowserProvider) {

  var options = {
      location: 'no',
      clearcache: 'no',
      toolbar: 'no'
  };

  $cordovaInAppBrowserProvider.setDefaultOptions(options);
});

www/templates/tab-dash.html

<ion-view view-title="Dashboard">
  <ion-content class="padding">
    <button type="button" name="button" ng-click="openLink()">Open</button>
  </ion-content>
</ion-view>

www/js/controllers.js

angular.module('starter.controllers', [])

.controller('DashCtrl', function($scope, $rootScope, $cordovaInAppBrowser) {

  $scope.openLink = function() {

    $cordovaInAppBrowser.open('http://www.google.co.cr', '_blank');
  };

  $rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event){

    console.log('start');
  });

  $rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){

    console.log('stop');
  });

  $rootScope.$on('$cordovaInAppBrowser:loaderror', function(e, event){

    console.log('error');
  });

  $rootScope.$on('$cordovaInAppBrowser:exit', function(e, event){

    console.log('exit');
  });
});

Even if I define the listener for every event, it doesn't seem to work. By the way, I'm using Ionic 2.1.8 with Angular 1.

Any help is appreciated, thank you!

NicholasMKim commented 7 years ago

Any update?

elbuki commented 7 years ago

Not really, I haven't found a solution since.

TomYiCL commented 7 years ago

Hi,Buddy,I added the plugin of InAppBrowser in my project, but when I run my project, the other plugins all did't work and myApp also became strange. how can I do?

elbuki commented 7 years ago

@TomYiCL Sorry, this issue is about the InAppBrowser, not plugins in general. You should post your question on the Ionic Forum or Stack Overflow to get pointers that could solve your problem.