I have multiple factories registered, say Circle
, Square
and Triangle
, and a controller called ShapeController
. Inside of ShapeController
, I'm trying to retrieve one of the factories using its string representation, in the same that I can fetch a controller using $controller('ControllerName', {...})
.
var ShapeController = function($scope, $routeParams, $factory) {
var shape = $factory('Circle', []); // shape is an instance of the Circle factory
....
}
I was hoping I could inject $factory
but I keep getting Error: [$injector:unpr] Unknown provider: $factoryProvider <- $factory <- ShapeController
. Is there any api or some way I could retrieve the factory?