我有以下模板:
<script type="text/x-handlebars" data-template-name="projects">
<div class="container-fluid">
<div class="row-fluid">
{{#linkTo "projects"}}Root{{/linkTo}}
{{#each controller}}
<div class="span4">
{{#linkTo "projects.show" this}}{{this.name}}{{/linkTo}}
</div>
{{/each}}
</div>
{{outlet}}
</div>
</script>
和:
<script type="text/x-handlebars" data-template-name="projects/show">
<h2>Overview of {{name}}</h2>
</script>
以及 app.js 中的以下内容:
App = Ember.Application.create({
LOG_TRANSITIONS: true
});
App.Project = DS.Model.extend({
name: DS.attr("string"),
key : DS.attr("string")
});
App.Router.map(function() {
this.resource("projects",function() {
this.route("show", {path: "/:project_id"});
});
});
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo("projects");
}
});
App.ProjectsRoute = Ember.Route.extend({
model: function() {
return this.store.find("project");
},
})
以及以下模型设置:
App.Store = DS.Store.extend({
adapter: DS.FixtureAdapter // run with fixture data
});
App.Project.FIXTURES = [
{
id: 1,
name: 'Proj1',
key: "P1KEY"
},
{
id: 2,
name: 'Proj2',
key: "P2KEY"
},
];
当我第一次导航到该页面时,我看到以下 3 个链接(Root、Proj1 和 Proj2)。因为我最初在索引视图中,所以我看到了这个:
然后,我点击第一个项目,我看到了这个:
而且,最后我回到索引,但项目/节目的内容似乎仍然存在:
谁能解释发生了什么?