<!DOCTYPE html>
<html ng-app="angularjs-starter">
<head lang="en">
<meta charset="utf-8">
<title>ngRepeat bug</title>
<script src="//github.com/diseaz/angular.js/raw/8b43e72b3c9590b4343b6510dcb6fb1d79814451/angular.js"></script>
<link rel="stylesheet" href="style.css">
<script>
document.write('<base href="' + document.location + '" />');
</script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
AngularJS branch: <a href="https://github.com/diseaz/angular.js/tree/t-repeat">here</a>
<h2>Array</h2>
<table>
<thead>
<tr>
<th></th>
<th>$index</th>
<th>Key</th>
<th>Value</th>
<th>[$index]</th>
<th>[key]</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in testList">
<td>
<a ng-click="RemoveFromList($index)">Remove($index)</a>
<a ng-click="RemoveFromList(key)">Remove(key)</a>
</td>
<td>{{$index}}</td>
<td>{{key}}</td>
<td>{{value[0]}}</td>
<td>{{testList[$index][0]}}</td>
<td>{{testList[key][0]}}</td>
</tr>
</tbody>
</table>
<form>
<input type="text" placeholder="Value" ng-model="testListValue"/>
<button ng-click="AppendToList()">Append</button>
</form>
<h2>Object</h2>
<table>
<thead>
<tr>
<th></th>
<th>$index</th>
<th>Key</th>
<th>Value</th>
<th>[$index]</th>
<th>[key]</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in testDict">
<td>
<a ng-click="RemoveFromDict(key)">Remove(key)</a>
</td>
<td>{{$index}}</td>
<td>{{key}}</td>
<td>{{value[0]}}</td>
<td>{{testDict[$index][0]}}</td>
<td>{{testDict[key][0]}}</td>
</tr>
</tbody>
</table>
<form>
<input type="text" placeholder="Value" ng-model="testDictValue"/>
<button ng-click="AppendToDict()">Append</button>
</form>
</body>
</html>
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.testList = [
['A', 'A'],
['B', 'B'],
['C', 'C'],
['D', 'D'],
['E', 'E'],
['F', 'F'],
['G', 'G'],
['H', 'H']
];
$scope.testDict = {
'A': ['A', 'A'],
'B': ['B', 'B'],
'C': ['C', 'C'],
'D': ['D', 'D'],
'E': ['E', 'E'],
'F': ['F', 'F'],
'G': ['G', 'G'],
'H': ['H', 'H']
};
$scope.RemoveFromList = function(idx) {
$scope.testList.splice(idx, 1);
};
$scope.AppendToList = function() {
if ($scope.testListValue) {
$scope.testList.push([$scope.testListValue, $scope.testListValue]);
}
};
$scope.RemoveFromDict = function(idx) {
delete $scope.testDict[idx];
};
$scope.AppendToDict = function() {
if ($scope.testDictValue) {
$scope.testDict[$scope.testDictValue] = [$scope.testDictValue, $scope.testDictValue];
}
};
});
/* CSS goes here */