我有一個使用ember-cli 0.2.3創建的Ember 1.11應用程序。我在router.js文件中的以下內容:獲取路由中父對象的ID
this.route('ownedGames', function() {
this.route('gamePlays', {path: ":owned_game_id/plays"}, function() { });
});
這允許我使用以下網址:
http://localhost:4200/ownedGames/1/plays
當我訪問該網址,我收到以下錯誤:
Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed '<[email protected]:owned-game::ember470:1>' (wrapped in (generated ownedGames.gamePlays controller))
這裏是我的遊戲路線
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
console.log("Getting game plays from store");
return this.store.find('gamePlay', {ownedGame: params.owned_game_id});
}
});
這是我是如何模仿我的燈具數據:
OwnedGame.reopenClass({
FIXTURES: [
{ id: "1", rating: "8.25", game: "1", plays: [1,2]},
{ id: "2", rating: "8.25", game: "2", plays: []},
{ id: "3", rating: "8.25", game: "3", plays: []},
{ id: "4", rating: "8.25", game: "4", plays: []}
]
});
GamePlay.reopenClass({
FIXTURES: [
{id: "1", date: "2015-01-01", ownedGame: "1"},
{id: "2", date: "2015-02-01", ownedGame: "1"}
]
});
轉換未定義。所以這不起作用。 – Gregg
@Gregg你應該有它可用https://github.com/emberjs/ember.js/blob/bfcc15ee3ac2b2b3e4dad6aa0d7a447936302f5a/packages/ember-routing/lib/system/route.js#L1327。如果你可以設置一個jsbin,我們可以調試furthur –
謝謝。我做了足夠的改變,我不確定這個問題有多有效。我會看看我是否可以編輯它是有道理的。 – Gregg