私のEmberアプリにはArrayController
、メソッドを作成した内部があります:
App.SwatchesController = Ember.ArrayController.extend({
push: function (color) {
var model = this.get('model');
/* do a few things */
this.set('model', model);
}
});
内のアクションからこのメソッドを呼び出そうとするとApplicationCotroller
、次のようになりますTypeError
。
App.ApplicationController = Ember.Controller.extend({
actions: {
parse: function () {
App.SwatchesController.push('#fff'); // TypeError: Object function (){/* long body here */} has no method 'push'
}
}
});
コントローラ メソッドは Ember で使用する必要があるものですか? 残念ながら、公式ドキュメントはコントローラーの限られた例しか提供していません。
おそらくモデルを として定義App.Swatches
し、 から直接管理することもできますApplicationController
が、そうすべきではないと思いSwatchesController
ます。