Reputation: 2084
I have a controller like this :
.controller('candidatureStartCtrl', function ($scope, $parse, fileUploadCtrl) {
//...code
fileUploadCtrl.uploadFile($scope.identityDocUpload);
//...code
}
in candidatureStartCtrl I'm calling another controller which is fileUploadCtrl
to use its function uploadFile()
.
but I get this error in console even though I imported the fileUploadCtrl
js in the index.html :
Error: [$injector:unpr] Unknown provider: fileUploadCtrlProvider <- fileUploadCtrl <- CandidatureStartCtrl
this is a fiddle with the same concept :
http://jsfiddle.net/7tzXh/143/
How can I solve this ?
Upvotes: 0
Views: 34
Reputation: 1937
$controller
is used to inject a controller into another. I've created a simple fiddle to make it clear.
Upvotes: 0
Reputation: 2737
You cannot inject controllers directly without using $controller as mentioned in one of the comments to the question. If you need to share data, you can use factory
or service
.
Please find the working fiddle here:
http://jsfiddle.net/7tzXh/144/
Upvotes: 1