Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  26] [ 2]  / answers: 1 / hits: 24212  / 9 Years ago, wed, june 24, 2015, 12:00:00

I have this controller



  .controller('ctrl', function($scope, $rootScope, $timeout, $alert, 
$location, $tooltip, $popover, BetSlipFactory,
AccordionsFactory, AuthFactory,
RiskWinCalculations) {...});


and, I am getting this error due to jshint:




line 10 col 44 This function has too many statements. (41)




so, what should I do to avoid it ?


More From » angularjs

 Answers
10

It doesn't mean poorly managed code as @pankajparkar says before, it could be because you have something like this, lets say this from one of my projects:



  $scope.betLoader = false;
$scope.showIfbetAlerts = true;
$scope.displayStraight = true;
$scope.displayParlay = true;
$scope.displayIfBet = true;
$scope.displayTeaser = true;
$scope.displayPleaser = true;
$scope.displayReverse = true;
$scope.unavailableBet = false;
$scope.subAccordion = false;
$scope.betTypeShow = false;
$scope.showStraight = true;


you can do this:



$scope.setInitialState = function() {
$scope.betLoader = false;
$scope.showIfbetAlerts = true;
$scope.displayStraight = true;
$scope.displayParlay = true;
$scope.displayIfBet = true;
$scope.displayTeaser = true;
$scope.displayPleaser = true;
$scope.displayReverse = true;
$scope.unavailableBet = false;
$scope.subAccordion = false;
$scope.betTypeShow = false;
};
$scope.setInitialState();


that will fix it.



UPDATE



Let me explain:



it is not only related with the dependencies, jslint throws this error when there are too many statements, he says before on line ten which is where the controller begins, so parting from there, he should have too many statements, if you put all those statements in 1 function, those statements will be reduce to 1 :)


[#66062] Tuesday, June 23, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;