我的问题是“简单”,但我不能与Ember解决这个问题....Ember路线如何?
这是一个小型图书馆应用程序,与作者和图书与路线做工精细
this.resource('books', function() {
this.route('edit', {path: '/:book_id/edit'});
this.route('show', {path: '/:book_id'});
});
this.resource('authors', function() {
this.route('new');
this.route('edit', {path: '/:author_id/edit'});
this.route('show', {path: '/:author_id'});
});
现在我要添加,让我登记新书的路线,利用从当前作者模板的链接/authors/156
路线必须打开一个books/new
模板,并与他author
链接new book
对象:即我想显示<h1>New book from {{author.name}}</h1>
我应该添加哪些路线到现有路线? 如何将作者参考传递给新书对象?
首先,感谢这个答案。也许我错了,但我不喜欢创建'author.newbook route'的想法。我更喜欢'book.new'。我正在尝试第一个选项'book/new /:author_id',但是现在我又陷入了另一个问题:如何将新书链接到作者。我认为它必须在'BookNewRoute'内完成,'model:function(){return this.store.createRecord('book')}'但是怎么做? –