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>
Related
hello guys i'm new to vue js and i'm trying to pass paramenters to a specific router this should happen when i click on a card research and then it will redirect to the research details component called actions-log but when i call this router via
this.$router.push({ name: "actions-log", params: { Id: "3" } })
it gives me an error in the console says:
Uncaught (in promise) Error: No match for {"name":"3","params":{}}
so can any one help me with that error please......
You can use path
const routeId = 3
this.$router.push({ path: `/actions-log/${routeId}` })
i figured out what's happening i have a component called pageTitle this component is included by every other component i use it to make the breadcrumb using the:
this.$route.fullPath
then spliting it and looping the values with :
<li><router-link></router-link></li>
to make the breadcrumbs links but the fullPath prop of the vue router it returns the params too so through the loop in:
<router-link :to="{ name: {path} }">{{ path }}</router-link>
vue checks if the router is exists with the given name, for example when i put /actions-log/3 as params int the url it will be set in the :to attribute becuase of this behavios it's launch that exception;
so i think i solved the problems in the following computed fuction :
i don't know if someone has a better idea to create a breadCrumbs in vue...
anyway thank you so much for helping me to resolve this problem.
I am working on a admin and client portal in Meteor JS using Iron:Router.
I know i can create a route using:
this.route('tasks',{path:'/projects', layoutTemplate: 'adminLayout'});
But is it possible to make a route with a sub directory such as:
this.route('tasks',{path:'/admin/projects', layoutTemplate: 'adminLayout'});
So that way i can also have a sub directory of:
this.route('/admin/projects', {name: 'admin.projects', template: 'projects', layoutTemplate: 'adminLayout'}
and
this.route('/client/projects', {name: 'client.projects', template: 'projects', layoutTemplate: 'adminLayout'}
Thanks for any input.
All the paths you have can coexist in one app quite happily.
The router (or your browser) doesn't have any concept of directories/subdirectories, all it understands are strings and regular expressions. The nesting is purely something we (should) create to enable ourselves to understand how an app/api(/codebase, etc) is structured.
As Sasikanth points out that is not the full error message. However looking at packages/iron_middleware-stack/lib/middleware_stack.js line 31 it's easy to confirm what is happening:
throw new Error("Handler with name '" + name + "' already exists.");
This is within the Router.route function, which is documented here.
Router.route('/post/:_id', {
// The name of the route.
// Used to reference the route in path helpers and to find a default template
// for the route if none is provided in the "template" option. If no name is
// provided, the router guesses a name based on the path '/post/:_id'
name: 'post.show',
// To support legacy versions of Iron.Router you can provide an explicit path
// as an option, in case the first parameter is actually a route name.
// However, it is recommended to provide the path as the first parameter of the
// route function.
path: '/post/:_id',
// If we want to provide a specific RouteController instead of an anonymous
// one we can do that here. See the Route Controller section for more info.
controller: 'CustomController',
// If the template name is different from the route name you can specify it
// explicitly here.
template: 'Post',
// and more options follow
So for the code you included above, you provide explicit paths. Therefore the first parameter is the route name. These must be unique as they are used to lookup the path in the pathFor, urlFor and linkTo helpers. As you are not providing an explicit template option, the name is also used for that, but your code is throwing this exception before it gets that far.
I think what you were trying to achieve is this:
this.route('/projects', {name: 'projects', template: 'tasks', layoutTemplate: 'adminLayout'});
this.route('/admin/projects', {name: 'admin.projects', template: 'tasks', layoutTemplate: 'adminLayout'});
this.route('/client/projects', {name: 'client.projects', template: 'tasks', layoutTemplate: 'adminLayout'});
I have installed the atmosphere package iron:router for my meteor application. I am trying to add a simple route like this:
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading',
notFoundTemplate: 'notFound'
});
Router.route('/', {
name : 'homeIndex'
});
I defined a template:
<template name="homeIndex">
<h1>Test for my meteor application</h1>
</template>
And I add a yield - field to my layoutTemplate:
<template name="layout">
<div class="container">
{{> yield}}
</div>
</template>
But still when I go to '/', I don't see anything of my template.
Also when I'm trying to add another route with another template, it doesn't work. I have installed the package through this command: meteor add iron:router
Can someone please tell me what I'm doing wrong?
If you want to render a template when a user goes to a particular route, you should use this.render('templateName');. In your case, you only defined a named route, but you didn't specify which template to render.
Router.route('/', function () {
this.render('homeIndex');
}, {
name: 'homeIndex'
});
When I looked at my console in the browser, I saw the iron router package was throwing an exception that EJSON was undefined in the javascript of the package. I installed the EJSON package with the command meteor add ejson, and it was fixed! But thanks anyway for the help!
So I've a route called 'find_project' as follows:
Router.map(function() {
this.route("/find_project");
}
And my template is as:
<template name="find_project">
<h1>Find project page</h1>
</template>
Obviously, one would expect the template to work, right? NO!
Couldn't find a template named "FindProject" or "findProject". Are you sure you defined it?
Now I camel-case the template name like so:
<template name="findProject">
<h1>Find project page</h1>
</template>
And magically, it started working.
Does Meteor enforce camel casing in template names?
Meteor does not enforce camel-cased names, the problem you're facing comes from iron:router trying to guess the template name from the route path, using a camel-cased heuristic by default.
If you prefer underscore based names, rewrite your routing function as :
Router.route("/find_project",{
template:"find_project"
});
Router.setTemplateNameConverter(_.identity);
from: https://github.com/EventedMind/iron-router/issues/1064
I'm new to MeteorJS. I was reading up Discover Meteor while trying to build an app of my own (instead of the demo app Microscope). When setting up a router.js I encountered this problem.
{{> yield}} in the layout Template is causing a blank page on / when I tried using name for routing:
Router.route('/', {name: 'home' })
(where home is a template defined in the client repository.)
Conclusion:
I checked my iron-router's version in .meteor/versions and realized it was 0.9.3, while the one in the demo app is 1.0.0.
I tried updating it
meteor update iron:router
but it can only be updated to 0.9.4 due to other packages I have. 0.9.4 is the latest compatible version.
So this appears to be a backward-compatibility issue. Somehow the function
Router.route(uri, {name: templateName });
doesn't seem to work with {{> yield}}, which is why I'm getting a blank page.
(although using {{yield}} would output the string [object object]).
Solution:
I used a different function to route instead
Router.route(templateName, {path: uri});
together with map:
Router.map ->
#route 'home',
path: '/'
return
#this is CoffeeScript