任意のルートに関連付けられたカスタム パラメータを保存したいと考えています。それらをルーターマップに保存することは可能ですか? 何かのようなもの:
this.route('aboutUs', {path: 'about-us', langIndex: '1'});
そして、どうすればコントローラーから langIndex 値を回復できますか?
任意のルートに関連付けられたカスタム パラメータを保存したいと考えています。それらをルーターマップに保存することは可能ですか? 何かのようなもの:
this.route('aboutUs', {path: 'about-us', langIndex: '1'});
そして、どうすればコントローラーから langIndex 値を回復できますか?
ルーター マップは、後でコントローラーで必要になる一時的なデータを格納するようには設計されていません。ユースケースのようなものを機能させるには、次のようにする必要があります。
App.AboutUsRoute = Ember.Route.extend({
langIndex: '1'
...
});
そして、ルートに対応するコントローラー内で、次のような変数を取得できます。
App.AboutUsController = Ember.ObjectController.extend({
someMethod: function() {
// get here the variable stored in your route
// this.get('target') always refers to the controller
// corresponding route
this.get('target').get('langIndex');
}
});
それが役に立てば幸い。