简体   繁体   中英

Emberjs rename '/' route

I often used routes with the path '/' to specify them as the default route. Now I noticed that it didnt work as expected with the link-to helper.

I used this in an older version of emberjs and I think it worked.

So when I have a language route with a dynamic segment which contains a courceCategories route that has the path '/' and use the {{#link-to "language" model}}click{{/link-to}} helper I get the following error:

Assertion failed: The attempt to link-to route 'language' failed (also tried 'language.index'). The router did not find 'language' in its possible routes: 'loading', 'error', 'languages', 'language.loading', 'language.error', 'language.courceCategories', 'index'

Why cant the router resolve this url?

demonstration: http://emberjs.jsbin.com/umeFeBe/2/edit

Thanks

This is a bug in Ember, and it's been reported here .

This PR should fix this, Try with the canary build once the PR is merged.

UPDATE: The PR has been merged, and this works now, check here

That's because you're overriding the language.index value when you do the route / path inside its function. You now need to link to language.courceCategories

<script type="text/x-handlebars" data-template-name="languages">
  {{#each this}}
    {{#link-to "language.courceCategories" this}}{{id}}{{/link-to}}
  {{/each}}
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM