【发布时间】:2015-06-09 00:18:29
【问题描述】:
我也是 Ionic 和 Angular UI 的新手。我正在尝试使用模板在我的 Ionic 应用程序中加载我的第一页。我的文件夹结构如下。
我想使用我的index.html 作为我所有模板的容器。我正在尝试使用list.html 作为模板,当我的应用程序首次加载时加载到index.html。我已经尝试了以下代码,但我被卡住了。
.config(function($urlRouterProvider, $stateProvider){
$stateProvider
.state('index', {
url: '/',
abstract: true,
templateUrl: 'index.html'
})
.state('index.list', {
url: '/list',
views: {
'list-index' : {
templateUrl: 'list.html',
controller: 'ListCtrl'
}
}
})
$urlRouterProvider.otherwise('/list');
})
我的index.html只有一个
<ion-nav-view name='list-index'></ion-nav-view> 在 body 标签内。
list.html 有一些代码通过使用控制器 ListCtrl 获取一些 JSON 内容来加载列表。
应用加载为空白。
我需要指出正确的方向。我认为我离正确的解决方案太近了。非常感谢任何帮助。谢谢。
为index.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="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.4.2.min.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
<ion-nav-view name='list-index'></ion-nav-view>
</body>
</html>
链接到app.js - http://codepen.io/anon/pen/RPVJao
【问题讨论】:
-
你有任何javascript错误吗?,你可以通过运行应用程序
ionic serve并检查chrome中的开发人员工具来检查
标签: angularjs angular-ui-router ionic-framework