配列のインデックス付けに問題があります。周りを見回すと、ビューhttp://jsfiddle.net/WSwna/14/を介してコントローラー内のアイテムにインデックスを付ける方法の例がいくつか見つかりました
私のアプリケーションは、次のように REST 呼び出しからデータを取得します
Videos.Store = DS.Store.extend({
revision: 12,
url: "http://localhost/",
adapter: Videos.Adapter
})
私のルーターは次のとおりです
Videos.Router.map(function(){
this.resource('videos', {path: '/'});
this.route('forms');
})
Videos.VideosRoute = Ember.Route.extend({
model: function(){
return Videos.Video.find();
}
});
そして、HTMLを次のように実装すると
{{#each controller}}
.....
{{/each}}
私のデータが表示されます。
ただし、リンクhttp://jsfiddle.net/WSwna/14/から例を実装したいのですが 、 Videos.VideosController を生成してそれを {{#each iterator}} に渡すことに問題があります
私の Videos.VideoController は次のようになります
Videos.VideosController = Ember.ArrayController.extend({
model: function(){
return Videos.Video.find();
}
});
Videos.VideoView = Ember.View.extend({
content: null,
adjustedIndex: function(){
return this.getPath('_parentView.contentIndex') + 1;
}.property()
});
しかし、次のようにHTMLでそれを使用すると:
{{#each Videos.VideosController }}
コンテンツに Ember.Array を実装する必要があるというエラーが表示されます。Videos.VideoController を渡しました。私が理解しているように、Ember は反復されるデフォルトの配列コレクションを提供しましたが、このコントローラーを拡張したいので、ビューに渡すデータの配列を作成するのが困難です。また、View コードがこの拡張コントローラーにどのように接続されているかも不明です。
これを明確にするのに役立つアイデアは大歓迎です。