Initial $scope.seatsin the controller:
$scope.seats = [];
And add below code to the template:
<input ng-model="seats.length">
<input ng-repeat="seat in seats track by $index" ng-model="seats[$index]">
when changed seats.lengthto 3it will temporarily add null to the array.
$scope.seats // [null, null, null]
Therefore, it must be used track by $indexto avoid problems with the same value.
Demo on plnkr here
source
share