Angular Multiple Repeats.

by Yashwanth M

HTML

<div id='mainC' ng-app="angularjs-starter" ng-controller="MainCtrl">
   <fieldset ng-model='y' ng-repeat="choice in choices">
      <select id='myOptions'>
         <option ng-model='x1' ng-repeat = "x in names">{{x}}</option>
      </select>
   </fieldset>
   <button class="addfields" ng-click="addNewChoice()">Add fields</button>
</div>

JavaScript

var app = angular.module('angularjs-starter', []);

  app.controller('MainCtrl', function($scope) {
  
  $scope.names = ['Mobile','Office','Home'];
  $scope.addedName = $scope.names;
  $scope.choices = [{id: 'choice1'}];
  
  $scope.addNewChoice = function() {
    var newItemNo = $scope.choices.length+1;

 // https://code.angularjs.org/1.2.32/docs/api/ng/function/angular.element
 // https://stackoverflow.com/a/20690490/5081877	
    var ele = document.getElementById('myOptions');
		var angularEle = angular.element( ele );
		console.log( angularEle );
    console.log( angularEle[0].value );
    
    var value = angularEle[0].value;
    $scope.names = $scope.names.filter(item => item !== value)
    console.log( $scope.names );

    $scope.choices.push({'id':'choice'+newItemNo});
  };
  
});