【发布时间】:2015-08-08 11:00:19
【问题描述】:
我正在使用带有 AngularJS 的 Ionic 框架,此时我还是个新手。我所有的州都在工作,除了一个,我找不到问题所在。我可以说我的第二个斜线导航不起作用。我无法导航到链接(“#/tabs/dash/Restaurant/test/test2”)
州:
.state('tab.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
.state('tab.restaurantlist', {
url: '/dash/Restaurant',
views: {
'tab-dash': {
templateUrl: 'templates/restaurant-list.html',
controller: 'RestaurantListController'
}
}
})
.state('tab.restaurantmenu', {
url: '/dash/Restaurant/:restaurantId',
views: {
'tab-dash': {
templateUrl: 'templates/restaurant-menu.html',
controller: 'RestaurantMenuController'
}
}
})
.state('tab.restaurantmenu.food', {
url: '/dash/Restaurant/test/test2',
views: {
'tab-dash': {
templateUrl: 'templates/restaurant-food.html',
controller: 'RestaurantFoodController'
}
}
})
最后一个有问题[.state('tab.restaurantmenu.food']。
控制器:
.controller('RestaurantFoodController', function () {
console.log("RestaurantFoodController");
})
我只是想看看,它的工作原理。所以我清除了函数的输入。
HTML:(我有 templates/restaurant-food.html,但它来自 templates/restaurant-menu.html,你们可以看到导航)
<ion-view view-title="{{restaurant.name}}">
<ion-content>
<ion-list>
<ion-item class="item item-avatar item-icon-right" ng-repeat="item in restaurant.menu" href="#/tabs/dash/Restaurant/test/test2">
<img src="../img/ionic.png" />
<h2>{{item.FoodName}}</h2>
<p>{{item.FoodDesc}}</p>
<span class="price">{{item.price}}</span>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
</ion-list>
</ion-content>
我再次强制项目导航到链接。
我能做什么,我必须学习什么?如果你们知道我的问题,你能告诉我吗?
【问题讨论】:
-
您的 resterauntmenu 视图上有 ui 视图吗?每次嵌套时,它都需要另一层模板。因此,由于这是第二级,您需要一个用于 resteraunmenu 模板的 ui-view,然后在该模板中为您的食物 html 提供一个 ui-view
-
@KevinF,我没有。我更新了菜单 html 的主题。我现在正在努力。感谢您的信息:)
标签: angularjs routes angular-ui-router ionic-framework ionic