Hi I just got tasked with maintaining a client written in AngjularJs and im not very familiar with Angjular but I just found this piece of code that I believe to be pure insanity..
There is a service that fetches an array of types from an API then attaches it to the rootScope
// just use a global, we'll need this array of types later $rootScope.opts = opts; The controller (which includes the service above)
//this cant be right $scope.$rootScope = $rootScope; $scope.setCategory = (type) => { // trust that the service has set the options into $rootScope const option = $scope.$rootScope.opts.find( typeOption => typeOption.name === type); return option; } I would think it better to store the "opts" array in the service and just invoke it from the controller when needed ?
But before I nuke this code I must know if there any sense in doing it this way