My query pertains to a JavaScript program with 2 controllers. The issue I am facing is the need for one function in both controllers (data.duration). This function serves two purposes, once for features themselves and once for the summary. Currently, this function is duplicated in the code...
Is there a way to utilize the function in both controllers efficiently?
(function() {
var loader = ['$http',
function($http) {
return $http.get('report.json')
.success(function(data) {
// Function declarations and logic here...
data.duration = function(feature) {
// Calculation logic goes here...
};
});
}
];
// Angular module definitions, configuration, and controller functions...
}());