Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Last active May 30, 2016 19:56
Show Gist options
  • Save hjumeau/bacfb617ac6dc4b8440c to your computer and use it in GitHub Desktop.
Save hjumeau/bacfb617ac6dc4b8440c to your computer and use it in GitHub Desktop.
NestedRoutes
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember 2.0'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<nav>
{{#link-to "articles" class='articles-link'}}Articles{{/link-to}}
{{#link-to "comments" class='comments-link'}}Comments{{/link-to}}
</nav>
<div class='application'>
{{outlet}}
</div>
<br>
<br>
Overview articles content
<br>
<br>
<nav>
{{#link-to "articles.new"
class='articles-new-link'}}New{{/link-to}}
{{#link-to "articles.overview"
class='articles-overview-link'}}Overview{{/link-to}}
</nav>
<div class='articles'>
{{outlet}}
</div>
<br>
<br>
<nav>
{{#link-to "comments.new" class='comments-new-link'}}New{{/link-to}}
</nav>
<div class='comments'>
{{outlet}}
</div>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('articles', function () {
this.route('overview');
this.route('new');
});
this.route('comments', function () {
this.route('new');
});
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
height:100%;
}
.articles-link {
color: #b71c1c;
}
.articles{
border: 1px solid #b71c1c;
padding: 20px;
}
.articles-new-link {
color: #ff5252;
}
.articles-overview-link {
color: #311b92;
}
.comments-new-link {
color: #01579b ;
}
.comments-link {
color: #1b5e20;
}
.comments{
border: 1px solid #1b5e20;
padding: 20px;
}
.application{
border: 1px solid lightgrey;
padding: 20px;
}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment