Skip to content

Commit

Permalink
add basic on and off buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyknown committed Dec 18, 2015
1 parent 0ecb91f commit 6aacdc0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Ember from 'ember';

export default Ember.Controller.extend({
isOn: null
});
16 changes: 16 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Ember from 'ember';

export default Ember.Route.extend({
setupController(controller) {
controller.set('isOn', false);
},
actions: {
turnOn() {
this.controllerFor('application').set('isOn', true);
this.set('isOn', true);
},
turnOff() {
this.controllerFor('application').set('isOn', false);
}
}
});
16 changes: 14 additions & 2 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<h2 id="title">Welcome to Ember</h2>
<div id="display">
{{#if isOn}}
ON
{{else}}
OFF
{{/if}}
</div>

{{outlet}}
<button {{action 'turnOff'}}>
OFF
</button>

<button {{action 'turnOn'}}>
ON
</button>
12 changes: 12 additions & 0 deletions tests/unit/controllers/application-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('controller:application', 'Unit | Controller | application', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.subject();
assert.ok(controller);
});

0 comments on commit 6aacdc0

Please sign in to comment.