मेरे पास राउटर खातों के साथ स्थापित है, और खाता /: account_id विकल्प हैं। जब उपयोगकर्ता मेरे ऐप के इंडेक्स पेज पर उतरता है तो मैं उन्हें खाता रूट में बदल देता हूं।एम्बर.जेएस: संक्रमण मार्ग के लिए, फिर गतिशील सेगमेंट
Social.Router.map(function() {
this.resource('accounts', function(){
this.resource('account', { path: ':account_id'});
});
});
Social.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('accounts');
}
});
मैं क्या करना चाहता हूं उन्हें कुछ मानदंडों के आधार पर निर्दिष्ट: account_id मार्ग में स्थानांतरित करना है। फिलहाल मैं सरणी में पहला खाता प्राप्त करना चाहता हूं और इसका उपयोग करना चाहता हूं। लेकिन भविष्य में वे उन्हें देख रहे अंतिम खाते में स्थानांतरित करने का एक तरीका हो सकते हैं। कुछ इस तरह:
Social.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('accounts/:account_id');
}
});
डॉक्स "विस्तार" दे लेकिन एक उदाहरण प्रदान नहीं करते, केवल की पेशकश निम्नलिखित:
transitionTo (name, models)
Transition into another route. Optionally supply a model for the route in question. The model will be serialized into the URL using the serialize hook.
मैं कोशिश की है निम्नलिखित:
this.transitionTo('accounts/4');
Uncaught Error: assertion failed: The route accounts/4 was not found
this.transitionTo('accounts', Social.Account.find(1));
Uncaught More objects were passed than dynamic segments
आपका बेवकूफ काम नहीं कर रहा था इसलिए मैंने इसे CDNjs.com से कॉल के साथ अपडेट किया: http://jsfiddle.net/XNyme/9/ – commadelimited