Hi, hopefully someone can shed some light on this for me. I've looked at the minject documentation quite a bit on this and I think I'm doing this exactly the way I'm supposed to, but this just doesn't work at all.
I have a class that contains 3 different js.html.DivElement member variables that I want to inject using mapValue(), but when I try this all I get is this error: "Uncaught TypeError: Cannot call method 'join' of undefined"
Here the class I want to inject into:
class TvDisplay {
@inject public var model:TvModel;
@inject("osd") public var osdElement:DivElement;
@inject("message") public var messageDialog:DivElement;
@inject("loading") public var loadingScreen:DivElement;
public function new() {
}
@post
public function initialize():Void {
trace('osdElement=$osdElement');
}
}
Here is my injection setup code:
var injector:Injector = new Injector();
injector.mapSingleton(TvModel);
var osdElement:DivElement = cast Browser.document.getElementById("osd");
var messageElement:DivElement = cast Browser.document.getElementById("messageDialog");
var loadingElement:DivElement = cast Browser.document.getElementById("loadingScreen");
injector.mapValue(DivElement, osdElement, "osd");
injector.mapValue(DivElement, messageElement, "message");
injector.mapValue(DivElement, loadingElement, "loading");
var instance:Bootstrap = injector.instantiate(Bootstrap);
The Bootstrap class I haven't included here, but it has a class member that is of type TvDisplay and is being injected properly. But whenever I try and use the mapValue() methods to map those DivElements, it never works at all and spits out that error I listed above.
I am able to get this all to work by manually creating an instance of TvDisplay, manually setting the 3 element field values, then using mapValue() to map the TvDisplay class, but I'd rather use named mappings that the documentation says is possible. Here is that code:
var display:TvDisplay = new TvDisplay();
display.osdElement = cast Browser.document.getElementById("osd");
display.messageElement = cast Browser.document.getElementById("messageDialog");
display.loadingScreen = cast Browser.document.getElementById("loadingScreen");
injector.mapValue(TvDisplay, display);
So that works fine, but again, I'd really rather use the named mappings to inject those DivElement objects. According to the documentation, it looks like this should work. Does mapValue() just not work with DOM elements or something? Thanks for any help.
-Jason