Skip to content

Instantly share code, notes, and snippets.

@code0100fun
Last active May 22, 2016 23:06
Show Gist options
  • Select an option

  • Save code0100fun/deea49cf3dd7482a2f17a7f54948875f to your computer and use it in GitHub Desktop.

Select an option

Save code0100fun/deea49cf3dd7482a2f17a7f54948875f to your computer and use it in GitHub Desktop.
Routing API
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Weekend'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('episodes', function() {
this.route('episode', { resetNamespace: true, path: '/' }, function() {
this.route('show', { path: '/:slug' });
});
});
this.route('about');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return params.slug;
}
});
This is the About page
<h1>Welcome to {{appName}}</h1>
{{link-to 'Episodes' 'episodes' }}
{{link-to 'About' 'about' }}
<p>
{{outlet}}
</p>
Episode Slug: {{model}}
<ul>
<li>
{{#link-to 'episode.show' 'episode-1'}}
Episode 1
{{/link-to}}</li>
<li>
{{#link-to 'episode.show' 'episode-2'}}
Episode 2
{{/link-to}}
</li>
</ul>
{{outlet}}
{
"version": "0.8.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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment