我的問題是「簡單」,但我不能與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')}'但是怎麼做? –