0
我正在與Ionic第一次合作,並且遇到了一些小問題。我已閱讀文檔和教程,但我無法弄清楚我做錯了什麼。無法使用Ionic渲染視圖
首先,這裏是我的代碼(我從一個空白項目開始)。
代碼
app.js(我剛加入一個狀態):
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['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, $urlRouterProvider) {
$stateProvider.state('home', {
url: '/',
views: {
templateUrl: 'templates/home.html'
}
})
$urlRouterProvider.otherwise('/');
});
的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>
<!-- compiled css output -->
<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>
</head>
<body ng-app="starter">
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-positive">
<ion-nav-back-button></ion-nav-back-button>
</ion-nav-bar>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-list>
<ion-item menu-close ui-sref="home">
Home
</ion-item>
</ion-list>
</ion-side-menu>
</ion-side-menus>
</body>
</html>
而且我認爲(在/www/templates/home.html
):
<ion-view view-title="Home">
<ion-content>
<div>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae inventore quod nihil quia, provident porro! Nulla ad libero deserunt, ullam soluta voluptates quidem dolore harum hic consequatur quas suscipit, ab.</div>
<div>Rerum, eum. Doloribus ullam voluptas repudiandae corrupti ipsa modi magnam, odit perferendis quam reprehenderit sapiente. Rerum impedit sequi voluptatibus porro ducimus dolor animi atque cupiditate similique praesentium. Beatae, suscipit, dolor.</div>
<div>Quasi natus cupiditate dignissimos non sed quaerat dolorem assumenda minima consectetur, quibusdam nostrum odio molestias voluptate eaque ut fugit atque quia totam laudantium? Repellendus ad, voluptatem itaque ut dolor placeat!</div>
<div>Quidem illo, molestias pariatur dolor laudantium et doloribus nostrum, hic quae consequuntur, nesciunt explicabo temporibus tempore possimus. Sint dolor, suscipit, iure, dolorem maiores veniam est cum eligendi iusto dolorum praesentium?</div>
<div>Dicta nihil amet, sapiente deserunt, facilis autem. Est debitis voluptate velit dicta explicabo alias culpa laborum nesciunt mollitia delectus, quos ut eius, itaque qui temporibus laudantium iusto reprehenderit omnis incidunt.</div>
</ion-content>
</ion-view>
T他問
好吧,所以基本上,我只想有一個視圖(並在稍後添加一些其他視圖)。此時,應在我提供應用程序時呈現我的主視圖,但標題(導航欄)和內容均顯示爲而不是。我已經嘗試了很多東西(我的app.js中的語法,緩存等)。但沒有任何工作。
你有什麼想法嗎? :) 謝謝 !