The way angular dependencies are handled currently is by accessing the injector on the document element, and then getting the dependency through the that injector instance.
This does not work for accessing locals that could normally be injected into a controller, for example. The work-around is to manually pass the known locals to the controller function. For example, in a directive controller function, $scope, $element, $attrs, $transclude, are all explicitly passed in. However, this does not allow user-defined locals.
I think the way dependencies are handled could use further development. One idea is to match more closely how dependencies are specified in angular. For example we could defined the controller as:
foreign import controller
"..."
:: forall e r i h a b c d
. String
-> Module
-> { | i }
-> ({ | h } -> ConstructorFnEff e r a b c d)
-> Eff (ngwmod :: WriteModule | e) Module
However, since we defined { | i} and { | h} using different type parameters, the access of the keys for inj are not constrained by what dependencies are passed in for { | i}. It would be ideal to somehow enforce a key constraint.
The way angular dependencies are handled currently is by accessing the
injector
on thedocument
element, and then getting the dependency through the that injector instance.This does not work for accessing locals that could normally be injected into a controller, for example. The work-around is to manually pass the known locals to the controller function. For example, in a directive controller function,
$scope
,$element
,$attrs
,$transclude
, are all explicitly passed in. However, this does not allow user-defined locals.I think the way dependencies are handled could use further development. One idea is to match more closely how dependencies are specified in angular. For example we could defined the controller as:
And use it like
However, since we defined
{ | i}
and{ | h}
using different type parameters, the access of the keys forinj
are not constrained by what dependencies are passed in for{ | i}
. It would be ideal to somehow enforce a key constraint.