gpt4 book ai didi

javascript - this.transitionToRoute 在没有参数的情况下不起作用

转载 作者:行者123 更新时间:2023-11-28 06:38:32 27 4
gpt4 key购买 nike

祝你好,StackOverflow,

// routes
Router.map(function() {
this.resource('myresource');
this.resource('myresource', { path: 'myresource/:param1' });
});

// call transition from controller when switch not selected any params
// doesn't work...
this.transitionToRoute('myresource');

需要帮助,如果未选择 View 中的任何参数,我想转到“domain.tld/myresource”。但这不起作用:(

最佳答案

// router
Router.map(function() {
this.route('myresource');
this.route('anothermyresource', { path: 'myresource/: param1' });
});

// router extend for another my resource
setupController: function(controller, model) {
this.controllerFor('myresource').setProperties({isNew:false, content:model});
},
renderTemplate: function() {
this.render('myresource');
},
model: function (params) {
if (params.param1 === 'paramValue') return this.store.find('resource', {param1: 0});
}

// and now work like as need
this.transitionToRoute('myresource');

关于javascript - this.transitionToRoute 在没有参数的情况下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34051030/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com