I am currently utilizing AngularJS and I am looking to retrieve a controller using one factory that is dependent on another.
This can be illustrated as follows:
MyCtrl -> Factory1 -> Factory2
I attempted to achieve this in three separate files (loaded in the following order):
Factory2.js
app.factory('Factory2', function () { ... })
Factory1.js
app.factory('Factory1',['Factory2', function (Factory2) { ... })
controller.js
app.controller('MyCtrl',['$scope', 'Factory1', function ($scope, Factory1) { ... })
Within my HTML code, I have included:
<script src="services/factory2.js" type="text/javascript"></script>
<script src="services/factory1.js" type="text/javascript"></script>
<script src="controllers/controller.js" type="text/javascript"></script>
Despite these efforts, I encountered an error:
Unknown provider: Factory2Provider <- Factory2 <- Factory1
What could be causing this issue? Am I overlooking something in my code?