Skip to content

Instantly share code, notes, and snippets.

@ryanjm
Last active October 9, 2015 03:42
Show Gist options
  • Save ryanjm/b59df1f187f836e5453c to your computer and use it in GitHub Desktop.
Save ryanjm/b59df1f187f836e5453c to your computer and use it in GitHub Desktop.
LinkTo Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
{{#link-to 'parent'}}Parent{{/link-to}}
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.modelFor('parent')['page-a'];
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.modelFor('parent')['page-b'];
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.modelFor('parent')['page-c'];
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return {
'title': "Parent Title",
'page-a': {"title": "Page A Title"},
'page-b': {"title": "Page B Title"},
'page-c': {"title": "Page C Title"}
}
}
});
{{model.title}}
<br/>
{{#link-to 'parent.page-a.index'}}Page A{{/link-to}}
{{#link-to 'parent.page-b.index'}}Page B{{/link-to}}
{{#link-to 'parent.page-c.index'}}Page C{{/link-to}}
<br/>
{{outlet}}
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('parent', function(){
this.route('page-a', function() {});
this.route('page-b', function() {});
this.route('page-c', function() {});
});
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.active {
background-color: red;
}
{
"version": "0.4.11",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.0.0-beta.1/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment