I am using Ember 3.18, I am facing the below issue. Consider the following routes:
Router.map(function() {
this.route('author');
this.route('author' , {path:"/author/:author_id"});
});
Now, in my hbs file, I am trying to transition to the above routes using a single LinkTo. As you can see, only the second route requires model attribute. In simple terms, I want to combine the below 2 into a single line.
<LinkTo @route="author" />
<LinkTo @route="author" @model="2" />
As you can see, I require the model attribute to be gone in certain cases and availble in certain cases.
Please help.
I think the easiest way forward is to tweak your routing setup a bit. I know you want to combine the routes, but it's hard/confusing, imo, and would be "more standard" to do something more traditional like:
and
author.indexwould match/authorandauthor.view(with a@model) would match/author/2.Note that index is an implicit convention of the web, and not needed in the router.js file