I\'m trying to inject an Ember service into an Ember Object but keep getting the following error:
\"Assertion Failed: Attempting to lookup an injected property o
Well you need to passing in the container instance when you create a instance of your model. The container is accessible in the route, controllers, components with this.get('controller')
. AFAIK basically anything created with the container gets the container property set. Thats why service injections work in controllers etc..
So if you are creating the model in a route's method. The code will look like below
App.IndexRoute = Ember.Route.extend({
model: function() {
var newModel = Model.create({
container: this.get('container')
});
return newModel.get('test').getText();
}
});
Here is a working demo.