tutulması, Rotası'na yönlendir Nasıl bir yolun model
kancası içinde.EmberJS:</p> <p>olarak bildiğim kadarıyla, tek yer <code>queryParams</code> erişmek için: Bir rota, <code>/new</code> yönlendirmesi ve <code>new</code> rota için sorgu params tutmak istiyorum sorgu parametreleri
Ama beforeModel
hook içinde yönlendirmek istiyorum: Yukarıdaki kod çalışır iken
import Ember from "ember";
export default Ember.Route.extend({
/**
* @@override
* Implicitly create a new applicant, redirecting to the generated ID at /applications/#{id}
* @param transition
*/
beforeModel: function(transition) {
var emptyApplicant = this.store.createRecord("applicant",
{isPrimary: true}
),
emptyApplication = this.store.createRecord("application");
emptyApplication.set("applicant", emptyApplicant);
emptyApplicant.save().then((savedApplicant) => {
emptyApplication.save().then((savedApplication) => {
this.transitionTo("applications", savedApplication);
});
});
}
});
geçiş sorgu params korumadan tamamlayacak. Örneğin, applicants/new?agent=35
'a gitmek, sorgu paramında agent=35
'u korumayacaktır ve bunun yerine applicants/new
'a yönlendirecektir.
nasıl Kor app beforeModel
kancadan queryParams
nesneye erişebilir?