【发布时间】:2015-05-29 20:45:50
【问题描述】:
这是一个非常有趣的问题,我没有找到任何答案。
我有不同的看法,如下图所示:
我有第一个包含三个视图的 html 文件,我正在使用下面的代码:
$stateProvider
.state('home', {
url: '/home',
views: {
day: {
templateUrl: 'home.html',
}
}
})
.state('help', {
url: '/help',
views: {
day: {
templateUrl: 'help.html'
}
}
})
.state('contact', {
url: '/contact',
views: {
day: {
templateUrl: 'contact.html'
}
}
})
在 html 文件中的容器:<ion-nav-view name="day"></ion-nav-view>
然后是第二个 HTML 文件,其中包含一个内容和几个视图,例如:
.state('c', {
url: '/c',
views: {
view: {
templateUrl: 'composition.html'
}
}
})
.state('h', {
url: '/h',
views: {
view: {
templateUrl: 'resume.html'
}
}
})
以及第二个 html 文件中的容器:<ion-nav-view name="view"></ion-nav-view>
当单击第一个 html 的任何视图的任何项目时,它应该重定向到具有两个视图的第二个 html 文件。
我应该真正使用什么??
我试过这样做:
制作一个 racine html 文件,它将两个 html 文件视为 ion-views:
然后像这样对状态提供者进行更改:
$stateProvider
.state('index.home', {
url: '/home',
views: {
day: {
templateUrl: 'home.html',
}
}
})
.state('index.help', {
url: '/help',
views: {
day: {
templateUrl: 'help.html'
}
}
})
.state('index.contact', {
url: '/contact',
views: {
day: {
templateUrl: 'contact.html'
}
}
})
.state('match.c', {
url: '/c',
views: {
view: {
templateUrl: 'composition.html'
}
}
})
.state('match.h', {
url: '/h',
views: {
view: {
templateUrl: 'resume.html'
}
}
})
.state('index', {
url: '/index',
abstract: true,
views: {
index: {
templateUrl: 'first.html'
}
}
})
.state('index.match', {
url: '/match',
views: {
day: {
templateUrl: 'second.html'
}
}
})
请问你怎么看??
【问题讨论】:
-
提供一个codepen?我也许可以帮助你!
-
感谢您的评论,plunker 代码:plnkr.co/edit/DNT9TTpS0HdaNShkZjSW?p=preview
标签: angularjs angular-ui-router ionic-framework