未在angularJS和Ionic中加载模板
Templates not loading in angularJS and Ionic
我设置了一个基本的ionic应用程序,其中包含一些视图和控制器。当我加载起始页时,我总是以$urlRouterProvider.otherwise('views/error.html');
行结束。也没有加载任何模板。。即使是错误.html.
我不知道为什么。我在控制台中没有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在您的视图文件夹中,并且有一些标记要渲染$urlRouteProvider.否则('directory/file.html')将始终在应用程序启动时首先加载。
所以我的解决方案是更改:
$urlRouterProvider.otherwise('views/error.html');
至:
$urlRouterProvider.otherwise('/');
相关文章:
- 未在angularJS和Ionic中加载模板
- 在Ionic应用程序上使用$.getScript加载谷歌地图Api
- Cordova AngularJS Ionic标签的内容在第一次加载时重叠
- 获取 window.location.reload 以在 Ionic 中仅加载一次
- ionic框架,在模板渲染后加载javaScript
- 在加载数据之前显示Ionic加载
- FileReader未在Ionic 2中加载端启动
- 自定义字体未在ionic中加载
- XMLHttpRequest 无法在 Ionic 登录到 odoo 服务器时加载 http://localhost:80
- 除非刷新,否则Firebase数据不会加载到列表中(AngularJS,Firebase和ionic)
- Jquery没有在ionic的
模板中加载 - 在ionic中重新加载控制器
- 加载的图像是'在ios Ionic Framework中不可见
- Ionic Angular JS$routeProvider加载离子列表获胜't滚动
- 如何等待所有js脚本都加载到IONIC(AngularJS)中
- Ionic框架未加载ng模型变量
- Ionic地图控制器没有被加载
- Ionic:更新$scope变量后重新加载视图
- Ionic无限滚动显示更多的项目已经加载(不是通过httprequest)
- 我如何修复XMLHttpRequest不能加载在Ionic上的面条支付