我設置了一個基本的離子應用程序,包含幾個視圖和控制器。當我加載首頁時,我總是以$urlRouterProvider.otherwise('views/error.html');
行結束。並沒有模板被加載,即使是error.html。不加載angularJS和Ionic的模板
我不知道爲什麼。我在控制檯或任何東西中都沒有出現js錯誤。有任何想法嗎?
這是我的代碼:
的HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers/LoginController.js"></script>
<script src="js/controllers/MainMenuController.js"></script>
<script src="js/controllers/SettingsController.js"></script>
</head>
<body ng-app="iou">
<ion-nav-view></ion-nav-view>
</body>
</html>
的JavaScript
var app = angular.module('iou', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state('index', {
url: '/',
templateUrl: 'views/login.html',
controller: 'LoginController'
});
$stateProvider.state('mainmenu', {
url: '/mainmenu',
templateUrl: 'views/mainmenu.html',
controller: 'MainMenuController'
});
$stateProvider.state('settings', {
url: '/settings',
templateUrl: 'views/settings.html',
controller: 'SettingsController'
});
$urlRouterProvider.otherwise('views/error.html'); // I always end up here
});
errors.html是我的看法是文件夾,它有一些標記。但是,該標記不會呈現。沒有標記,應用程序只是重定向到錯誤的網址,但它是空白的.. – Weblurk 2015-04-04 08:41:54