Skip to content

Instantly share code, notes, and snippets.

@visoft
Last active February 23, 2016 01:50
Show Gist options
  • Save visoft/a2f18fba5ff547a88b94 to your computer and use it in GitHub Desktop.
Save visoft/a2f18fba5ff547a88b94 to your computer and use it in GitHub Desktop.
Complex Computed Property Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Complex Computed Property Test'
});
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<span class="navbar-brand">{{appName}}</span>
</div>
<ul class="nav navbar-nav">
<li>{{#link-to "valuations"}}Valuations{{/link-to}}</li>
<li>{{#link-to "qr"}}QR{{/link-to}}</li>
</ul>
</div>
</nav>
{{outlet}}
<br>
<br>
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
valuations: DS.hasMany('valuation', { async: false })
});
import DS from 'ember-data';
export default DS.Model.extend({
type: DS.attr('string'),
marketValue: DS.attr('number')
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
<div class="container">
<h1>QR</h1>
</div>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('valuations');
this.route('qr');
});
export default Router;
{
"version": "0.6.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.3.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js",
"bootstrap-css": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css",
"bootstrap-js": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js",
"mockjax" : "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.min.js"
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
init() {
this._super(...arguments);
$.mockjax({
url: '/properties',
responseText: [{ id: 1, name: 'Foo Company', valuations: [ { id: 10, type: "NEW" }] },
{ id: 2, name: 'Bar Corp', valuations: [ { id: 20, type: "NEW" }] }]
});
},
model() {
return $.getJSON('/properties');
}
});
<div class="container">
<h1>Valuations</h1>
{{#each model as |property|}}
<h3>{{property.name}}</h3>
{{/each}}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment