Skip to content

Instantly share code, notes, and snippets.

@kubz
Last active October 24, 2019 18:48
Show Gist options
  • Save kubz/ea87caac9e7e86fe55ae2e531f843f57 to your computer and use it in GitHub Desktop.
Save kubz/ea87caac9e7e86fe55ae2e531f843f57 to your computer and use it in GitHub Desktop.
nested route
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('fruitroute', { path: '/fruit/:fruitName' }, function() {
this.route('rotten', { path: 'rotten' });
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
return params.fruitName;
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
a.active {
background: red;
color: yellow;
font-weight: bold;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
display: inline;
border: solid;
border-width: 1px 1px 0 1px;
margin: 0 5px 0 0;
}
li a {
padding: 0px 10px;
}
#content {
border: 1px solid;
}
li a.active {
padding-bottom: 1px;
}
<h1>Welcome to {{appName}}</h1>
<br>
in red/yellow you can see active links
<br><br>
{{#link-to "fruitroute.index" "apple"}}go to my Apple{{/link-to}}<br>
{{#link-to "fruitroute.rotten" "apple"}}go to my rotten Apple{{/link-to}}
<br>
{{#link-to "fruitroute.index" "strawberry"}}go to my Strawberry{{/link-to}}<br>
{{#link-to "fruitroute.rotten" "strawberry"}}go to my rotten Strawberry{{/link-to}}
<hr>
{{outlet}}
<br>
<br>
<h1>fruit page: {{model}}</h1>
<ul>
<li>{{#link-to "fruitroute.index" model}}Main Tab{{/link-to}}</li>
<li>{{#link-to "fruitroute.rotten" model}}Rotten Tab{{/link-to}}</li>
</ul>
{{outlet}}
<section id="content">
<h2>main tab content here</h2>
</section>
<section id="content">
<h2>rotten tab content here</h2>
</section>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment