Non-singletons that are registered in a container are actually singletons when they get dependency injected

I want to inject an instance of a certain controller into every instance of a certain view type. The view is rendered/instantiated with:

{{view "view-name"}}

from within a template. I passed in {singleton: false} as options object for App.register but the controller is still only instantiated once. How to ensure that every view object gets its very own controller instance? See this jsbin: http://jsbin.com/kaqos/4/

I realized that it has nothing to do with {{view}}. The same thing happens when looking up a view class directly. e.g.

App.__container__.lookup("view:injected-slot")
App.__container__.lookup("view:injected-slot")
App.__container__.lookup("view:injected-slot")

will create 3 new view instances but the injected alternatives instance is always the same.

So I have digged into the code of lookup() and found out that lookup() searches for the class to instantiate and then caches it. Injections will only get looked up when the class is not cached yet, which leaves the injected dependency as a singleton no matter if singleton is set to false in register().

I’m not sure if this is a bug or works as intended.

this is a known bug, and an issue exists tracking it.