Skip to content

Instantly share code, notes, and snippets.

@frank06
Last active October 28, 2015 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frank06/ca6ca8b76bf135e3af6c to your computer and use it in GitHub Desktop.
Save frank06/ca6ca8b76bf135e3af6c to your computer and use it in GitHub Desktop.
auctions
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Auction Service',
bidService: Ember.inject.service()
});
<h1>Welcome to {{appName}}</h1>
{{outlet}}
<br>
Auctions:
<ul>
{{#each bidService.auctions as |auction| }}
<li>{{#link-to 'auction' auction.id}} {{auction.title}}{{/link-to}}, price: {{auction.price}}</li>
{{/each}}
</ul>
import Ember from 'ember';
export default Ember.Service.extend({
auctions: [
{ id: 1, price: 19, title: "T-shirt"},
{ id: 2, price: 226, title: "iPhone 5"},
{ id: 3, price: 170, title: "Pony toy"},
{ id: 4, price: 5, title: "Methylene blue"}
],
getHighestBidForAuction(id) {
},
_multiplier: 1.03,
bidSimulator: function() {
setInterval(() => {
console.log('in interval')
this.get('auctions').forEach(a => {
Ember.set(a, 'price', (a.price * this._multiplier).toFixed(2));
})
}, 3000)
}.on('init')
});
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('auction', { path: ':id'});
});
export default Router;
{
"version": "0.4.14",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment