<!DOCTYPE html>
<html ng-app="agendaEditor">
<head>
	<meta charset="UTF-8">
	<title>Form AgendaEditor</title>
	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
	<script src="controller.js"></script>
</head>
<body ng-controller="formCtrl">
	<h2>Form AgendaEditor</h2>
	<table>
		<tr>
			<td>Title</td>
			<td>Name</td>
			<td>Surname</td>
			<td></td>
		</tr>
		<tr ng-repeat="item in list" ng-click="$last && addItem()">
			<td><input type="text" ng-model="item.title"></td>
			<td><input type="text" ng-model="item.name"></td>
			<td><input type="text" ng-model="item.surname"></td>
			<td ng-if="!$first"><button ng-click="list.splice($index, 1)">-</button></td>
		</tr>
	</table>
	<button ng-click="addItem()">Add</button><br />
	Wynik:
	<div ng-repeat="item in myResult() track by $index">{{item}}<br /></div>
</body>
</html>
var app = angular.module('agendaEditor', []);
 
app.controller('formCtrl', function($scope) {
	$scope.list = [];
  
	$scope.list.push({title: "", name: "", surname: ""});

	$scope.myResult = function () {
		var result = [];
		for (var i = 0; i < $scope.list.length; i++) {
			var concat = "„" + $scope.list[i].title + "” – " + $scope.list[i].name + " " + $scope.list[i].surname;
			if($scope.list[i].title !== ""){
				result.push(concat);
			}
		}
		return result;
	};
	
	$scope.addItem = function(){
        $scope.list.push({title: "", name: "", surname: ""});
	};
});