this.transitionToRoute 没有参数不起作用

this.transitionToRoute doesn't work without params

你好,Whosebug,

// 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');

需要帮助,如果未在视图中选择任何参数,我想转至 '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'); 

你应该像这样嵌套你的路线:

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

这应该会为您提供您所请求的 URL 路线,而无需变通,并清理您的 Route/View/Controller/Component 名称。