var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.data = [
{Title: 'One'},
{Title: 'Two'},
{Title: 'Three'}
];
});
app.directive('onChange', function() {
return {
link: function(scope, element, attrs) {
element.on('change input', function() {
scope.$eval(attrs.onChange);
scope.$digest();
});
}
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.20/angular.js" data-semver="1.2.20"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<table>
<tr data-ng-repeat="item in data" on-change="item.changed = true" ng-class="{edited: item.changed}">
<td>Changed: {{item.changed}}</td>
<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.Age" />
</td>
</tr>
</table>
</body>
</html>
/* Put your css in here */
tr td {
padding: 5px;
}
tr.edited {
background: #EEE;
}