Phonegap: Angular Controller does not work in a new window

I am working on a project based on PhoneGap 3.5and Angular.js. I am trying to use the Angular New InAppBrowser window with the following controller:

var gWindow;
window.loadWindow = function(website) {
    gWindow = window.open(website, '_blank', 'location=no');
    gWindow.addEventListener('loadstart', function(event) { 
        //alert('start: ' + event.url); 
    });
    gWindow.addEventListener('loadstop', fLoadStop);
    gWindow.addEventListener('loaderror', function(event) { 
        //alert('error: ' + event.message); 
    });
    gWindow.addEventListener('exit', fExit);
}
window.fLoadStop = function(event) {
    var url = event.url;
    var filename = url.substring(url.lastIndexOf('/')+1);
    if(filename == "closeinappbrowser.html"){
        gWindow.close();
    }
}
window.fExit = function(event) {
    gWindow.removeEventListener('loadstop', fLoadStop);
    gWindow.removeEventListener('exit', fExit);
}

But I do not know why the controller below does not work in the new appbrowser window, but it works in the dekstop browser

newsappblank = angular.module("newsappblank", ["ngRoute", "newsControllersblank", "newsServices", "ngSanitize", "ui.bootstrap", "slugifier", "bn-lazy"]);

newsappblank.config([
    "$routeProvider", function($routeProvider) {
      return $routeProvider.when("/news/:newsId", {
        templateUrl: "partials/news-detail.html",
        controller: "NewsDetailCtrl"
      }).otherwise({
        redirectTo: "../closeinappbrowser.html"
      });
    }
  ]);

newsControllersblank = angular.module("newsControllersblank", []);
    newsControllersblank.controller("NewsDetailCtrl", [
        "$scope", "$rootScope", "$location", "$anchorScroll", "$http", "$routeParams", function($scope, $rootScope, $location, $anchorScroll, $http, $routeParams) {
          $rootScope.middlebar = true;
          $rootScope.loadbar = false;
          alert(1);
          return $scope.go = function(path) {
            if (path !== '/news/') {
              $location.path(path);
              $location.hash("top");
              return $anchorScroll();
            }
          };
        }
      ]);
+4
source share
1 answer

I had a problem: Phonegap Inapp Browser does not support loading Jquery Load to load an Angular template, so the solution is that I write an html template for the variable and call it.

0
source

Source: https://habr.com/ru/post/1547363/


All Articles