1
我想从另一个控制器获取控制器。
从另一个控制器从emberjs获得一个控制器
应用程序定义
var App = Ember.Application.create();
App.Router.map(function() {
this.route("index", {path: "/"});
this.resource('markets', {path: "/markets"}, function() {
this.route("sources");
});
});
定义路线
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('markets');
}
});
App.MarketsRoute = Ember.Route.extend({
model: function() {
return App.Markets.find();
}
});
App.MarketsRoute = Ember.Route.extend({
model: function() {
return App.Markets.find();
}
});
App.MarketsSourcesRoute = Ember.Route.extend({
model: function(){
return App.Sources.find();
},
serialize: function(model) {
return { markets_id: model.id };
}
});
控制器定义
App.MarketsSourcesController = Ember.ObjectController.extend({
need: ['nav'],
testmethod: function(){
this.get("content").clear();
}
});
App.MarketsController = Ember.ObjectController.extend({
test:function(){
//****************************************//
MAIN AREA
//****************************************//
}
});
我会在测试应用程序的App.MarketsController的调用TestMethod的()() .MarketsController。
对此,我已经使用this.controllerFor()和this.get()
但这些dosent工作。 我想要。