index.html
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.error{
border-color: darkred;
}
</style>
</head>
<body ng-app="test" ng-controller="ctrlTest" ng-init="validator = validator">
<ng-form name="mForm" matrix-validator data-all="validator">
<table>
<tr ng-repeat="row in matrix" ng-init="rowId = $index">
<td ng-repeat="item in row track by $index">
<input ng-model="row[$index]" type="number"
data-row="rowId" data-col="$index"
name="item{{rowId}}_{{$index}}"
ng-class="{error: mForm['item'+rowId+'_'+$index].$invalid}"
>
</td>
</tr>
</table>
</ng-form>
<script src="../node_modules/angular/angular.js"></script>
<script src="validatorDep.js"></script>
<script src="../src/matrix-validation.js"></script>
<script>
angular.module('test', ['matrixValidation']).controller('ctrlTest', [
'$scope',
($scope) => {
$scope.matrix = [
[0,0,0],
[0,0,0],
[0,0,0]
];
$scope.test=2;
$scope.validator = validator;
}
]);
</script>
</body>
</html>