gpt4 book ai didi

javascript - WindowsPhone 8 (phonegap) 和 AngularJs - $routeProvider 不工作?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:30 24 4
gpt4 key购买 nike

我的心已经不在了。我不知道我的代码有什么问题。

嗯,我会解释的。

文件详细信息:

Cordova 2.9.1 版本

angularjs 1.2.13 版本(也使用了最新(1.2.16)版本的所有版本)

我用过 Windows Phone 8 应用程序

这是我的代码

App.js

'use strict';
window.myApp = angular.module('myApp', ['ajoslin.mobile-navigate', 'ngMobile',
'myApp.Registermdl',
'myApp.login', 'myApp.CreateUsermdl', 'myApp.viewMap', 'myApp.createMap',
'myApp.logout', 'ngProgress', 'ngCookies','ngRoute'])


myApp.config(function ($routeProvider, $compileProvider) {

$compileProvider.aHrefSanitizationWhitelist(/^\s*(http?|ftp|mailto|file|tel):/);

$routeProvider.when('/', { templateUrl: 'index.html', controller: 'IndexCtrl' });
$routeProvider.when('/login', { templateUrl: 'app/login/login.html', controller: 'LoginCtrl' });
$routeProvider.when('/home', { templateUrl: 'app/home/home.htm', controller: 'HomeCtrl' });
$routeProvider.when('/createuser', { templateUrl: 'app/CreateUser/createUser.html', controller: 'CreateUserCtrl' });
$routeProvider.when('/signup', { templateUrl: 'app/register/register.html', controller: 'RegisterCtrl' });
$routeProvider.when('/logout', { templateUrl: 'app/login/login.html', controller: 'LogoutCtrl' });
$routeProvider.when('/view-map', { templateUrl: 'app/ViewMap/viewmap.html', controller: 'ViewMapCtrl' });
$routeProvider.when('/create-map', { templateUrl: 'app/CreateMapAddress/create-mapaddress.html', controller: 'CreateMapAddressCtrl' });
$routeProvider.otherwise({ redirectTo: '/' });
});

myApp.controller('IndexCtrl', ['$rootScope', '$scope', '$location', '$route', '$cookieStore', '$cookies',
function ($rootScope, $scope, $location, $route, $cookieStore, $cookies) {
if ($cookieStore.get('userEmail') == undefined) {
$rootScope.IsLogin = false;
$rootScope.IsLogout = true;
$rootScope.IsAdmin = false;
$rootScope.userName = "";
$scope.$apply();
if ($location.$$path == "/signup") {
$location.$$path = "/signup";
$route.reload();
return false;
}
$location.$$path = "/login";
$route.reload();
alert("goos Start5");
return false;
}
$rootScope.IsAdmin = false;
if ($cookieStore.get('userRole') == "Admin") {
$rootScope.IsAdmin = true;
}
$rootScope.IsLogin = true;
$rootScope.IsLogout = false;
$rootScope.userName = $cookieStore.get('userEmail');
$route.reload();

}]);
//var hostname = 'qbsnewsvr/CollegeApp';
var hostname = 'localhost:54938/';
var rootUrl = 'http://' + hostname;

和索引页(主页)

<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<!-- Use the .min version of bootstrap files in production -->
<!-- Use the following if you want to use responsive design -->
<link rel="stylesheet" type="text/css" href="dist/css/bootstrap-custom.css">
<link rel="stylesheet" type="text/css" href="dist/css/toastr.min.css">
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- Scripts begins-->

<script src="assets/js/jquery.min.js"></script>
<script src="dist/js/bootstrap.js"></script>
<script src="assets/js/offcanvas.js"></script>
<link href="css/MSDList.css" rel="stylesheet" />
</head>

<body>
<!-- The following tag is in place of ng-view to use the angular mobile view navigation framework
https://github.com/ajoslin/angular-mobile-nav
-->
<div class="navbar navbar-default navbar-fixed-top" role="navigation" ng-controller="IndexCtrl">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">College App</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#/home">Home</a></li>
<li><a href="#/home">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control input-sm" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#/home">Separated link</a></li>
<li><a href="#/home">One more separated link</a></li>
</ul>
</li>
</ul>
<div ng-show="IsLogin">
<p class="navbar-text welocome-aliginment">Welcome <a href="#" class="wecome-text" id="welcomeName">{{userName}}</a></p>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#/login" ng-show="IsLogout">Login</a></li>
<li><a href="#/signup" ng-show="IsLogout">SignUp</a></li>
<li><a href="#/createuser" ng-show="IsLogin && IsAdmin">Create New User</a></li>
<li class="active" ng-show="IsLogin"><a href="#/view-map">View Map</a></li>
<!-- <li class="active" ng-show="IsLogin"><a href="#/create-map">Create Map</a></li>-->
<li class="active" ng-show="IsLogin"><a href="#/logout">Logout</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container" ng-view></div>
<!-- Comment out the following 2 lines to test on the browser-->
<script type="text/javascript" src="cordova.js"></script>

<!-- In production use min versions -->
<script src="js/q.js"></script>
<script src="lib/angular/jx.min.js"></script>
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<script src="lib/angular/angular-mobile.js"></script>
<script src="lib/angular/mobile-nav.js"></script>
<script src="lib/angular/angular-cookies.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<!-- 3rd party libraries -->
<script src="js/toastr.min.js"></script>
<script src="lib/ngProgress/ngProgress.min.js"></script>
<script src="lib/MSDList.js"></script>

<!-- app js -->
<!-- <script src="http://maps.google.com/maps?file=api&v=3&key=AIzaSyBbd_4N1j8WIoRJ0trcrqGLlo0a6T_e-bA"></script>-->
<!-- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;ver=3.5.1"></script>-->

<!-- <script src="lib/Clusterer2.js"></script>-->
<!-- controller -->
<script src="js/app.js"></script>
<script src="app/home/home.js"></script>
<script src="app/register/register.js"></script>
<script src="app/CreateUser/createUser.js"></script>
<script src="app/login/login.js"></script>
<script src="app/ViewMap/viewmap.js"></script>
<script src="app/Login/logout.js"></script>
<script src="app/CreateMapAddress/create-mapaddress.js"></script>
<!-- logger -->
<script src="js/logger.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>

我的代码在所有浏览器上运行良好。但仅在模拟器中不起作用。我已经尝试了很多方法。

我从 Stack overflow 得到了一些答案

这行有配置

$compileProvider.aHrefSanitizationWhitelist(/^\s*(http?|ftp|mailto|file|tel):/);

但我已经这样做了。一切正常。但是 $routeProvider 在模拟器中不工作。(这意味着页面不会重定向到索引页面)。

我不知道。是版本问题还是什么冲突问题等等...

谁能帮帮我

最佳答案

要修复 window 移动应用程序的 angularjs 路由,请为不安全添加“ms-appx”:ms-appx://。

$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|file|ms-appx):/)

关于javascript - WindowsPhone 8 (phonegap) 和 AngularJs - $routeProvider 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com