Model not being injected
My model does not seem to get injected into my service class, I keep getting a Cannot access a property or method of a null object reference error.
in my context I have the following:
injector.mapSingleton(MenuModel);
in my service class I Inject the model like so:
[Inject] public var model:MenuModel;
Am i missing something?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Paul Robertson on 30 Jun, 2011 06:58 PM
A couple of other "easily to overlook" things to check:
- Is your Service class mapped (e.g. using injector.mapSingleton()) or
are you creating an instance yourself?
- In your Service class, are you accessing "model" in the constructor?
Injected properties aren't available in the constructor (you can use a
method marked with [PostConstruct] instead).
Paul
Support Staff 2 Posted by Stray on 30 Jun, 2011 07:56 PM
Hi Joe - incase what Paul has said doesn't cover it - we have a section on null injection errors in our 'common problems' document:
https://github.com/robotlegs/robotlegs-framework/wiki/common-problems
3 Posted by visnik on 30 Jun, 2011 07:59 PM
Paul,
I found the problem, I was creating an instance my self in my command. Thanks.
Stray closed this discussion on 01 Jul, 2011 10:03 AM.