我有一个简单的离子项目。我的index.html
显示了我所做的任何更改。但是,我试图包含一个模板文件。这没有在网页上显示。这是我的代码:
的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="cordova.js"></script>
<!-- your app's js -->
<script src="app/app.js"></script>
</head>
<body ng-app="eliteApp">
<ion-nav-view></ion-nav-view>
</body>
</html>
app.js
angular.module("eliteApp", ["ionic"])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouteProvider) {
$stateProvider
.state('home', {
url: "/home",
templateUrl: "app/home/home.html"
});
// if none of the above states are matched, use this as the fallback
$urlRouteProvider.otherwise('/');
});
home.html的
<ion-nav-bar class="bar-balanced">
<h1 class="title">Elite Schedule</h1>
</ion-nav-bar>
<ion-tabs class="tabs-energized tabs-icon-top">
<ion-tab title="Leagues" icon="ion-home" href="#">
<ion-view></ion-view>
</ion-tab>
<ion-tab title="My Teams" icon="ion-star" href="#">
<ion-view></ion-view>
</ion-tab>
</ion-tabs>
我正在关注教程。但是,我没有看到任何将模板导入我的index.html
文件的特定代码。我错过了什么吗?
答案 0 :(得分:1)
您的默认状态为/
,但您没有使用网址/
配置状态。
所以.. /home
应该有效:
$urlRouteProvider.otherwise('/home');
答案 1 :(得分:0)
在您的index.html
中的html中:
<body ng-app="eliteApp">
<ion-nav-view></ion-nav-view>
</body>
<ion-nav-view>
是将您的其他观点与此相关联的内容。因此,只要您的templateUrl
正确无误,只要您输入地址.../home'
即可。要将其设为默认home.html
,请将$urlRouteProvider
更改为$urlRouteProvider.otherwise('/home')
。
答案 2 :(得分:0)
好的,所以有一个错误。相反或$urlRouterProvider
,我写了$urlRouteProvider
,两个地方都没有r
。现在页面显示,但我看不到标题文字! : - /