Skip to content

Instantly share code, notes, and snippets.

@grapho
Forked from alexspeller/application.controller.js
Last active October 26, 2015 17:20
Show Gist options
  • Save grapho/93df63d075ac7eb1aee5 to your computer and use it in GitHub Desktop.
Save grapho/93df63d075ac7eb1aee5 to your computer and use it in GitHub Desktop.
Clock Serivice
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Clock Service',
clock: Ember.inject.service()
});
<h1>{{appName}}</h1>
{{clock.hour}}:{{clock.minute}}:{{clock.second}}
import Ember from 'ember';
export default Ember.Service.extend({
tick: Ember.on('init', function() {
if (this.isDestroyed) return;
var now = new Date();
this.setProperties({
second: now.getSeconds(),
minute: now.getMinutes(),
hour: now.getHours()
});
Ember.run.later(this, 'tick', 1000);
})
});
{
"version": "0.4.13",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment