ion-view 没有出现在 ion-nav-view 中
ion-view doesn't appear inside ion-nav-view
完成一些教程后,我开始使用我自己的 Ionic 应用程序。我开始使用 ionic 的空白模板。我的问题是我的 ion-view
(在 cards.js 中,见下文)根本没有出现在 ion-nav-view
中,即我没有得到任何子 HTML 标签至 ion-nav-view
.
我使用 Adam 对 this question 的回答来确保我的路由设置正确,我没有收到任何错误,所以我认为它们是正确的。我不是想有标签,只是一个视图。
如果我在我的控制器函数中放置一个断点,执行不会暂停,显然代码根本不会执行,但我很难深入框架的内部来弄清楚发生了什么。
你知道我在这里 missing/doing 错了吗?
我的代码是:
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>
<!-- libs-->
<script src="lib/ionic-contrib-tinder-cards/ionic.tdcards.js"></script>
<script src="lib/collide/collide.js"></script>
<!-- your app's js -->
<script src="app/app.js"></script>
<script src="app/controllers/cards.js"></script>
</head>
<body ng-app="myApp">
<ion-nav-view></ion-nav-view>
</body>
</html>
app.js
angular.module('myApp', ['ionic'])
.run(function($ionicPlatform, $rootScope) {
$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();
}
});
})
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('cards', {
url: '/cards',
views: {
'cards': {
templateUrl: 'app/views/cards.html',
controller: 'Cards'
}
}
});
$urlRouterProvider.otherwise('/cards');
});
cards.js
angular.module('myApp')
.controller('Cards', function($scope) {
$scope.cards = [
{title: 'Card-1'},
{title: 'Card-2'},
{title: 'Card-3'}
];
});
cards.html
<ion-view view-title="cards">
<ion-content ng-controller="Cards">
<h1> Cards view </h1>
<ion-list>
<ion-item ng-repeat="cards in cards">
{{card.title}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
我认为您应该使用其中之一。 ion-nav-view 只是一个行为略有不同的离子视图。
所以将 ion-view 放在 ion-nav-view 中类似于将 ion-view 放在 ion-view 中,后者无法正确显示。
来自文档:"and remember to replace ui-view with ion-nav-view in examples"
参考:
我已经删除了之前的post,因为你指出我的回复完全错误。
关于你的路由,这是我的。你看到那个合成器有什么不同吗?
$urlRouterProvider.otherwise('/');
$stateProvider.state('camera',{
url:"/camera",
cache: false,
controller:"CameraCtrl",
templateUrl:'app/views/loading/index.html'
})
完成一些教程后,我开始使用我自己的 Ionic 应用程序。我开始使用 ionic 的空白模板。我的问题是我的 ion-view
(在 cards.js 中,见下文)根本没有出现在 ion-nav-view
中,即我没有得到任何子 HTML 标签至 ion-nav-view
.
我使用 Adam 对 this question 的回答来确保我的路由设置正确,我没有收到任何错误,所以我认为它们是正确的。我不是想有标签,只是一个视图。
如果我在我的控制器函数中放置一个断点,执行不会暂停,显然代码根本不会执行,但我很难深入框架的内部来弄清楚发生了什么。
你知道我在这里 missing/doing 错了吗?
我的代码是:
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>
<!-- libs-->
<script src="lib/ionic-contrib-tinder-cards/ionic.tdcards.js"></script>
<script src="lib/collide/collide.js"></script>
<!-- your app's js -->
<script src="app/app.js"></script>
<script src="app/controllers/cards.js"></script>
</head>
<body ng-app="myApp">
<ion-nav-view></ion-nav-view>
</body>
</html>
app.js
angular.module('myApp', ['ionic'])
.run(function($ionicPlatform, $rootScope) {
$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();
}
});
})
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('cards', {
url: '/cards',
views: {
'cards': {
templateUrl: 'app/views/cards.html',
controller: 'Cards'
}
}
});
$urlRouterProvider.otherwise('/cards');
});
cards.js
angular.module('myApp')
.controller('Cards', function($scope) {
$scope.cards = [
{title: 'Card-1'},
{title: 'Card-2'},
{title: 'Card-3'}
];
});
cards.html
<ion-view view-title="cards">
<ion-content ng-controller="Cards">
<h1> Cards view </h1>
<ion-list>
<ion-item ng-repeat="cards in cards">
{{card.title}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
我认为您应该使用其中之一。 ion-nav-view 只是一个行为略有不同的离子视图。
所以将 ion-view 放在 ion-nav-view 中类似于将 ion-view 放在 ion-view 中,后者无法正确显示。
来自文档:"and remember to replace ui-view with ion-nav-view in examples"
参考:
我已经删除了之前的post,因为你指出我的回复完全错误。
关于你的路由,这是我的。你看到那个合成器有什么不同吗?
$urlRouterProvider.otherwise('/');
$stateProvider.state('camera',{
url:"/camera",
cache: false,
controller:"CameraCtrl",
templateUrl:'app/views/loading/index.html'
})