Angularjs array

var app = angular.module(‘plunker’, []);

app.controller(‘MainCtrl’, function($scope) {
$scope.options = [‘A’, ‘’, ‘var3’];
for (i = 0; i < $scope.options.length; i++){
if ($scope.options[i] == ‘A’){
//alert($scope.options[i]);
$scope.options[i].remove;
// $scope.options = [‘A’, ‘’, ‘var3’];
// alert(options[i].length) <-- count: 2

    // $scope.options = ['A', 'd', 'var3']; 
    // alert(options[i].length) <-- count: 3
    
    // $scope.options = ['', '', 'var3']; 
    // alert(options[i].length) <-- count: 1
 }

}

});

Please clarify your question so that everybody can give you a quick response. However, as what I’ve understand based on your pseudo code, you want to remove the index of an array if given string is matched. You can use the .splice in javascript.

$scope.options = ["A","B","C","D"];
var arrLen = $scope.options.length,
    i;

for(i = 0; i < arrLen; i++){
      if($scope.options[i] == "A"){
           $scope.options.splice(i, 1);
           alert($scope.options.length);
      }
}

Hope it helps!

thank you
But I do not go back to what I want and there is a problem.

  1. scope.options = [“A”,“A”,“B”,“B”] <-- 3 count!
  2. scope.options = [“A”,"","","",""] <- 3 count !

code test: http://jsfiddle.net

Here it is

https://jsfiddle.net/9ehmouq9/1/