1
我正在使用科爾多瓦建設一個android應用。我正在使用angularjs ui-router進行路由。 ui-sref完全不起作用。下面是我的代碼:ui-sref不工作在科爾多瓦android應用
var angularApp = angular.module('angularApp', [
'ui.router',
'ngTouch',
'angular.filter',
'angularApp.services',
'angularApp.controller',
]);
angularApp.config(function($stateProvider, $locationProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'templates/home.html',
})
.state('settings', {
url: '/settings',
templateUrl: 'templates/settings.html',
});
$urlRouterProvider.otherwise('/home');
});
在家狀態加載默認情況下,當我點擊鏈接的設置上,它無法正常工作。
下面是index.html中的代碼
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<!--
Customize this policy to fit your own app's needs. For more guidance, see:
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
Some notes:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="css/index.css">
<link rel="stylesheet" href="css/custom.css">
<link rel="stylesheet" href="css/icomoon.css">
<!-- Path to Framework7 Library CSS-->
<link rel="stylesheet" href="lib/framework7/css/framework7.material.min.css">
<link rel="stylesheet" href="lib/framework7/css/framework7.material.colors.min.css">
<base href="file:///android_asset/www/" target="_blank">
</head>
<body>
<script type="text/javascript" src="lib/angular/angular.min.js"></script>
<script type="text/javascript" src="lib/angular/angular-ui-router.js"></script>
<script type="text/javascript" src="lib/angular/angular-filter.min.js"></script>
<script type="text/javascript" src="lib/angular/angular-touch.min.js"></script>
<script type="text/javascript" src="js/angularjs-app.js"></script>
<script type="text/javascript" src="lib/framework7/js/framework7.min.js"></script>
<div id="welcome-wrap">
<div class="logo"><img src="img/logo.png"/></div>
<div class="preloader"></div>
</div>
<div ng-include="'templates/common-left-panel.html'"></div>
<div class="views">
<!-- Your main view, should have "view-main" class-->
<div class="view view-main">
<div class="navbar">
<div class="navbar-inner">
<div class="left">
<a href="#" class="link icon-only open-panel"> <i class="icon icon-navicon"></i></a>
</div>
<div class="center">
<h3>app</h3>
</div>
<div class="right">
<a href="#" class="link icon-only search-icon"> <i class="icon icon-search"></i></a>
<a ui-sref="settings" class="link icon-only setting-icon"> <i class="icon icon-gear"></i></a>
</div>
</div>
</div>
<!-- Main page content with bottom tab bar -->
<div class="pages navbar-fixed">
<a href="#/settings">Settings</a>
<div ui-view></div>
</div>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/framework-app.js"></script>
<script type="text/javascript" src="js/controllers.js"></script>
<script type="text/javascript" src="js/services.js"></script>
</body>
</html>
您是否正在設置ng-app屬性?例如:__
__ –我實際上在cordova deviceready事件上引導角度。 angular.bootstrap(document,['angularApp']); },false); 還不夠? –
它應該工作。可以肯定的是,把一個__console.log(「test」)__放在__angularApp.config__上面,看看這個日誌是否可以工作 –