My objective is to achieve the following:
(function(){angular.module('app').factory("loadDataForStep",ls);
ls.$inject = ['$scope','stepIndex']
function ls ($scope, stepIndex) {
if ($routeParams.code != undefined) {
$scope.code = $routeParams.code;
$scope.retrieveData($routeParams.code);
}
$rootScope.stepIndex = stepIndex-1;
$rootScope.currentStep = stepIndex;
$rootScope.resultsLoaded = false;
if (!fieldDefinitionsLoaded) {
loadAllElementsDefinition();
loadStepsWithOverrides(stepIndex, loadStep);
} else {
loadStep(stepIndex);
}
}
})();
Although I am aware of several issues in this code snippet, my current focus is on addressing the question: How can I successfully inject $scope and pass step index as a parameter? It is evident that $scope must be obtained from Angular, while the step index needs to be provided. Any assistance would be greatly valued.