Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Link-to Model not Working
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
// Broken on 2.10.2
// Works as expected on 2.9.1
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
name: attr('string'),
invoices: hasMany('invoice')
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
number: attr('string'),
client: belongsTo('client')
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('single', {path: '/:id'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(){
var client = this.store.createRecord('client', {name: 'Ross'});
this.store.createRecord('invoice', {number: 'R0001', client: client});
this.store.createRecord('invoice', {number: 'F0002', client: client});
return this.store.peekAll('invoice');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<div class="row">
{{#each model as |invoice|}}
{{#link-to "single" invoice.client}}
{{invoice.number}}: {{invoice.client.name}}
{{/link-to}}<br/>
{{else}}
No clients to show
{{/each}}
</div>
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment