Skip to content

Instantly share code, notes, and snippets.

@hibariya
Last active January 10, 2016 05:17
Show Gist options
  • Save hibariya/bc8eda6659978964e198 to your computer and use it in GitHub Desktop.
Save hibariya/bc8eda6659978964e198 to your computer and use it in GitHub Desktop.
Container returns falsy value as undefined on 2nd or later lookup
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
inspectLookup() {
return Ember.inspect(this.container.lookup('falsy:false'));
},
firstLookup: Ember.computed(function() {
return `1st lookup: ${this.inspectLookup()}`;
}),
secondLookup: Ember.computed(function() {
return `2nd lookup: ${this.inspectLookup()}`;
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{this.firstLookup}}<br>
{{this.secondLookup}}<br>
{{outlet}}
<br>
<br>
export function initialize(container, application) {
application.register('falsy:false', false, { instantiate: false });
}
export default {
name: 'application-init',
initialize: initialize
};
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "canary",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "canary"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment