You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a route with subroutes has an alias, then accessing the parent model in a subroute via this.modelFor requires knowing whether the route was accessed via the alias or the original name.
Moreover, transitioning between /one/a and /alias-one/a re-triggers one's model hook and this.modelFor('one') in ...routes/one/a.js will still return the old model hook result (i.e. from the previous transition to /one/a).
Testcase: Add two files:
/tests/dummy/app/routes/one/a.js
import Route from '@ember/routing/route';
export default Route.extend({
model() { return `parent model is '${this.modelFor('one')}' (alias-model is '${this.modelFor('alias-one')}')`; }
})
/tests/dummy/app/routes/one.js
import Route from '@ember/routing/route';
export default Route.extend({
model() { return `dummy model ${new Date().toTimeString()}`; }
})
Then show the model in tests/dummy/app/templates/a.hbs (and possibly alias-a.hbs), e.g. by adding <em> {{model}} </em>
and navigate a bit between /one/a, alias-one/a and other routes.
Here, too, I am not sure this behaviour can be mitigated, but since I found it quite astonishing I would have preferred to learn about it from the readme.
The text was updated successfully, but these errors were encountered:
Yes, I'm not really getting how this package can be used for an dynamic routing. We have
this.route('campaigns'); // this is the index, done before good Ember pattern of using index file
this.route('campaign', { path: 'campaign/:campaign_id' }, function() {
this.route('details');
});
And I want to alias the campaign resource to be standardized plural if navigating within it: this.alias('campaigns', 'campaigns/:campaign_id', 'campaign');
so I could go either /campaign/x/details or /campaigns/x/details.
...but in the alias, this fails to provide the expected modelFor('campaign'). Not sure how to use this package for this at all.
When a route with subroutes has an alias, then accessing the parent model in a subroute via
this.modelFor
requires knowing whether the route was accessed via the alias or the original name.Moreover, transitioning between
/one/a
and/alias-one/a
re-triggersone
'smodel
hook andthis.modelFor('one')
in...routes/one/a.js
will still return the old model hook result (i.e. from the previous transition to/one/a
).Testcase: Add two files:
Then show the model in
tests/dummy/app/templates/a.hbs
(and possiblyalias-a.hbs
), e.g. by adding<em> {{model}} </em>
and navigate a bit between /one/a, alias-one/a and other routes.
Here, too, I am not sure this behaviour can be mitigated, but since I found it quite astonishing I would have preferred to learn about it from the readme.
The text was updated successfully, but these errors were encountered: