bbc
November 10, 2014, 7:15pm
1
Following example
this.route('app', {path: ''}, function() {
this.resource('test');
});
<script type="text/x-handlebars" data-template-name="app/test">
test
</script>
<script type="text/x-handlebars" data-template-name="app">
[html wrapper...]
{{outlet}}
</script>
I would like to have a resource route in order to use my fixture data. But all I get is my html wrapper when I call the test route in my browser… When I switch back to a “normal” route my test template (output ‘test’) is correctly rendered. What am I doing wrong?
this.route
cannot have anything nested within… You can only nest within a resource, so:
this.resource('app', {path: ''}, function() {
this.resource('test');
});
But then you are saying that app is the index?
so don’t nest at all, just do:
this.resource('test');
and then define a template for index
.
bbc
November 10, 2014, 8:21pm
3
Thanks for the good advice! But unfortunately, it doesn’t work either
And for the nesting/not nesting thing: I simplified my example, i need the top-level ‘app’ for authentication later
I think resources always work unnested, and you have to specify the nesting manually. Routes nest.
If you really need ‘test’ to be a resource and not a route, I think you should be able to use something like (untested):
this.resource('app', {path: ''}, function() {
this.resource('app.test');
});
bbc
November 10, 2014, 8:35pm
5
Thanks, but that wouldn’t make any sense
Why should I say that test belongs to app, if it is hierachically already specified?
From what I’ve understood, the hierarchical nesting determines which routes get called, while this.resource/this.route determines their naming structure.
I can’t say I find it all that logical, but they’re not the same thing.
@bbc so what happens exactly? No data, an error? Would be nice if you could put together a jsbin (emberjs.jsbin.com )
bbc
November 10, 2014, 9:06pm
8
Great idea! But how can i change the url which is shown in the output of jsbin? By default, it goes into app.index