Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  161] [ 1]  / answers: 1 / hits: 26121  / 7 Years ago, thu, march 9, 2017, 12:00:00

I am trying this code in atom with ESLint



Code snippet:



$scope.IsVisible = false;
$scope.ShowHide = function () {
$scope.IsVisible = $scope.IsVisible ? false : true; // error
};


Got this ESLint error:
error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary



Tried with these solutions solution 1 and solution 2, but error is not fixed. Furthermore, code works fine in editor without ESLint.


More From » angularjs

 Answers
9

Try the good way =). No need to use statements in this case.



$scope.IsVisible = !$scope.IsVisible;

[#58604] Wednesday, March 8, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
iselauniquef

Total Points: 443
Total Questions: 98
Total Answers: 102

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
;