<!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>
</tr>
<tr ng-repeat="item in list">
<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>
</tr>
</table>
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 = [];
for(var i = 0; i < 3; i++) {
$scope.list.push({title: "", name: "", surname: "", time: ""});
}
$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;
};
});