希望我能解释清楚。首先,我使用ng-admin,我知道如何为每个这是:创建一个自定义视图。
我试图弄清楚如何在同一个自定义页面中创建嵌套视图。具体来说,我有一个视图,需要在页面上有3列--每个列都有它们的功能(和服务)。
示例:
在下面的图片中,我有3个视图。
访问此页面的url应该是myapp.com/ng-admin/#collections/collections/collection/1 (1是要查看/编辑的项的id )。

我的代码:
//collections state
myApp.config(function ($stateProvider) {
$stateProvider.state('collections', {
abstract: true,
parent: 'ng-admin',
url: '/collections/',
controller: collectionsCtrl,
templateUrl: '/app/collectionsView.html'
});
//collection state
myApp.config(function ($stateProvider) {
$stateProvider.state('collections.collection', {
parent: 'ng-admin',
url: '/collections/collection/:ID',
controller: collectionCtrl,
templateUrl: '/app/collectionView.html'
});
... ommiting first two controllers然后在集合项控制器中,我有:
myApp.controller('ItemViewCtrl', ['$scope', 'Events', '$stateParams', '$sce', function($scope, Events, $stateParams, $sce) {
$stateParams.ID && Collection.find($stateParams.ID).then(function(item) {
$scope.item = item;
});
$scope.view = function(id) {
$state.go('days.day', {
'ID': id
})
};
}]);我的collectionsView.html
<div ng-include src="'/app/tpl/collectionView.html'" include-replace>
</div>
<div class="inner-content full-height" ui-view></div>在我的collectionView.html里
<ul>
<li ng-repeat="collections as collection" >
<a ui-sref="collections.collection.id">
Link to collection
</a>
</li>
<ul>我当前的问题:
我可以获得集合/集合来显示这两个视图,但它不会显示第一列。
如果我只访问集合/我只能看到第一个列(但前提是我从$stateParam路由器选项中删除了抽象:true)。
少了什么?
发布于 2017-02-24 22:37:57
已解决:
这帮助我认识到,我不需要父属性或url的第一部分,因为当我作为statecollections.collection的一部分时,它们都是从父继承的。
//collection state
myApp.config(function ($stateProvider) {
$stateProvider.state('collections.collection', {
// parent: 'ng-admin', <-REMOVED
url: '/collections/collection/:ID', // Didn't need the /collections part of the url
controller: collectionCtrl,
templateUrl: '/app/collectionView.html'
});https://stackoverflow.com/questions/42449279
复制相似问题