Module 使用emberjs从另一个控制器获取一个控制器
我想从另一个控制器获取控制器。Module 使用emberjs从另一个控制器获取一个控制器,module,controller,ember.js,Module,Controller,Ember.js,我想从另一个控制器获取控制器。 应用程序定义 var App = Ember.Application.create(); App.Router.map(function() { this.route("index", {path: "/"}); this.resource('markets', {path: "/markets"}, function() { thi
应用程序定义
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的test()中调用App.MarketsController的testmethod()。为此,我使用了this.controllerFor()和this.get() 但这些都起作用了。
我想使用它。使用“需要”在另一个控制器中使用一个控制器
App.MarketsController = Ember.ObjectController.extend({
needs: ['marketsSources'],
test:function(){
this.get('controllers.marketsSources').testmethod();
}
});