我正在开发基于PhoneGap 3.5
和Angular.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();
}
};
}
]);
答案 0 :(得分:0)
我遇到了问题,Phonegap Inapp浏览器不支持Jquery加载加载角度模板,因此解决方案是我将html模板写入变量并调用它。