0

I have an array $scope.blinkingBoxes=[1,3,2]

I have another array called $scope.clickedBoxes and I push few values in it.

Now if(angular.equals($scope.blinkingBoxes, $scope.clickedBoxes)){doSomething()} checks if the both the arrays are same (i.e. same elements in same order)

However I want to check if the second array do not contain any element from first array and perform some action. How can I achieve this?

Thinker
  • 5,326
  • 13
  • 61
  • 137

2 Answers2

1

There is no such built-in function

you can use this

angular.forEach(array1, function(value, key) {
angular.forEach(array2, function(value_1, key_1) {
    if (value === value_1) {
        // condition or action
    }
});

});

Vikash Kumar
  • 1,712
  • 1
  • 11
  • 17
0
count = 0;
angular.forEach($scope.blinkingBoxes, function(value, key) { 
    if(value.indexOf($scope.clickedBoxes) == -1) {
        //not in same order or not same elements action goes here
        count++;
    }
});

if(count == $scope.blinkingBoxes.length) {
    //second array do not contain any element from first array, action goes here
}
Suresh Gogu
  • 359
  • 5
  • 12