Javascript 使用this.transitiono更改查询参数会导致错误
使用几乎来自Ember.js文档的复制粘贴Javascript 使用this.transitiono更改查询参数会导致错误,javascript,ember.js,typeerror,Javascript,Ember.js,Typeerror,使用几乎来自Ember.js文档的复制粘贴 App.CresShowResultController = Ember.ArrayController.extend({ queryParams: ['county'], county: null, actions: { displayQueryData: function(){ this.transitionTo({queryParams: {county: 'someCounty'}});
App.CresShowResultController = Ember.ArrayController.extend({
queryParams: ['county'],
county: null,
actions: {
displayQueryData: function(){
this.transitionTo({queryParams: {county: 'someCounty'}});
},
},
});
分析表单后,从另一个控制器调用该操作。
我得到一个错误:UncaughtTypeError:undefined不是一个函数
这也是路线
App.CresShowResultRoute = Ember.Route.extend({
renderTemplate: function(){
this.render('showResult');
}
});
旁白:如何使用Transitiono直接从另一个控制器更改URL参数,而不使用action displayUseryData作为中间人函数
编辑:添加my Router.map以指定:
App.Router.map(function(){
this.resource('cres', function() {
this.route('showResult');
});
this.resource('about');
this.resource('posts', function() {
//child route posted inside the parent
this.resource('post', { path: ':post_id'});
});
});
像往常一样,谢谢你的帮助 试试看:
App.CresShowResultController = Ember.ArrayController.extend({
queryParams: ['county'],
county: null,
actions: {
displayQueryData: function(){
this.transitionTo({queryParams: {county: 'someCounty'}});
}.bind(this),
},
});
我认为displayQueryData函数中的这是一个窗口引用。在上面引用的情况下,只需更新queryParam本身就会产生您想要的效果 在路由中,您可以定义这些查询参数是替换url,还是刷新模型 当您希望切换到其他路线或不同型号时,请使用TransitionRoute
App.CresShowResultController = Ember.ArrayController.extend({
queryParams: ['county'],
county: null,
actions: {
displayQueryData: function(){
this.set('county', 'someCounty');
// this.transitionTo({queryParams: {county: 'someCounty'}});
},
},
});
谢谢,但没用。还将this.transitiono更改为this.transitionoRoute,但所有组合均无效。