Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inject to controllers #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/initializers/storage-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export function initialize() {
let application = arguments[1] || arguments[0];
application.inject('route', 'storage', 'service:storage');
application.inject('component', 'storage', 'service:storage');
application.inject('controller', 'storage', 'service:storage');
}

export default {
Expand Down
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions tests/dummy/app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';

export default Controller.extend({
storageValues: computed('storage.{name,email,message,mouseX,mouseY}',
function(){
var obj = {};

if(this.get('storage.name') !== undefined){
obj.name = this.get('storage.name');
}
if(this.get('storage.email') !== undefined){
obj.email = this.get('storage.email');
}
if(this.get('storage.message') !== undefined){
obj.message = this.get('storage.message');
}
if(this.get('storage.mouseX') !== undefined){
obj.mouseX = this.get('storage.mouseX');
}
if(this.get('storage.mouseY') !== undefined){
obj.mouseY = this.get('storage.mouseY');
}

return obj;
}),
});
11 changes: 10 additions & 1 deletion tests/dummy/app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ input, textarea {
margin: 20px;
}
textarea {
height: 200px;
height: 50px;
}
div {
width: 100%;
Expand All @@ -31,3 +31,12 @@ div {
border-radius:50%;
margin: -4px 0 0 -4px;
}

table {
border-collapse: collapse;
}

table, th, td {
padding: 5px;
border: 1px solid grey;
}
16 changes: 16 additions & 0 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ around, and fill out the form.

{{storage-demo}}

<div>
<b>Storage values</b>
<table>
<tr>
<th>key</th>
<th>value</th>
</tr>
{{#each-in storageValues as |key value|}}
<tr>
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
{{/each-in}}
</table>
</div>

<p>
<a href="http://github.com/jerel/ember-storage">Download the code</a>
</p>
Expand Down