How bind ng-model to element inside ng-repeat? In fact i want to bind object in array to element and when type in input element create new input element with new ng-model. while in this example all ng-model are same.
var myApp = angular.module('app', []);
myApp.controller("MyCtrl",function($scope){
$scope.items = [];
$scope.item = {
phone:""
};
$scope.items.push($scope.item);
$scope.addItem = function(index){
if($scope.items[index+1] == null)
$scope.items.push($scope.item);
console.log($scope.items);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="MyCtrl">
<div ng-repeat="line in items track by $index">
<!-- typing here should auto update it's preview above -->
<input ng-model="line.phone" ng-keydown="addItem($index)"/>
<!-- many other fields here that will also affect the preview -->
</div>
</div>