祝您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');


需要帮助,如果没有在视图上选择任何参数,我想转到“ 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');

08-19 09:01