Hello,
I have a controller that contains a function I want to use in a directive.
How can I inject that controller into the directive?
I tried
.directive("cstUpload",
function(itemController){ // <== want to inject "itemController" in
this directive
return {
restrict: "AE",
link: function(scope,element,attrs){
element[0].addEventListener("change",function(attrs){itemController.uploadFiles(attrs);});
}
}
}
);
which gives (in Firebug console)
Error: [$injector:unpr] Unknown provider: itemControllerProvider <-
itemController <- cstUploadDirective
http://errors.angularjs.org/1.2.10/$injector/unpr?p0=itemControllerProvider%20%3C-%20itemController%20%3C-%20cstUploadDirective
directive("cstUpload",
function($itemController){
gives
Error: [$injector:unpr] Unknown provider: $itemControllerProvider <-
$itemController <- cstUploadDirective
directive("cstUpload",["$itemController"
function($itemController){
...
])
gives
Error: [$injector:unpr] Unknown provider: $itemControllerProvider <-
$itemController <- cstUploadDirective
but these don't work. The error occurs in AngularJS line 9400 so it's hard
for me to figure out what part of my code generates the error. No such
thing as a stacktrace in FireBug.
Thanks,
Marc
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.