‘Invalid left-hand side in assignment’ error when using the NOT(!) operator

I’m using this function:

$scope.myFunction = function(indexParent, childrenLength) {

    // close all inner accordion tabs
     for(i=0; i < childrenLength; i++) {
       !$scope.lettersandnumbers[indexParent].things[i].open = $scope.lettersandnumbers[indexParent].things[i].open;

    // toggle parent tab
    $scope.lettersandnumbers[indexParent].open = !$scope.lettersandnumbers[indexParent].open;


Here: <button ng-click="myFunction(0, 3)">Toggle a</button>
However the ‘close all inner accordion tabs’ section is giving me the Invalid left-hand side in assignment error. How can I alter the code to make it work?


Many Thanks


answer with a few amendments: https://plnkr.co/edit/aMD5rGxpe48lziTb6xPk?p=preview

Source: AngularJS