Phonegap: Angular Controller不能在新窗下工作

Phonegap : Angular Controller does not work in new window

本文关键字:新窗下 工作 不能 Controller Angular Phonegap      更新时间:2023-09-26

我正在做一个基于PhoneGap 3.5Angular.js的项目。我尝试使用Angular的New Window InAppBrowser和以下控制器:

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);
}

但是我不知道为什么下面的控制器不能在新窗口appbrowser中工作,但在dekstop浏览器中工作

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();
            }
          };
        }
      ]);

我有问题,Phonegap Inapp浏览器不支持Jquery加载加载Angular模板,所以解决方案是我写html模板到一个变量,并调用它