Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
<input ng-model='field1'>Change</input>
<input ng-model='field2'>Change</input>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.$watch(function($scope) {return hash($scope);}, function() {console.log("changed");});
}
function hash(obj, done) {
done = done || [];
var k, v, type;
var result = '';
for (k in obj) {
v = obj[k];
type = typeof (v);
if (type == 'object') {
done.push(v);
if (done.indexOf(v) == -1) {
result += k + hash(v);
}
} else if (type == 'number' || type == 'string'){
result += shash(k + v);
}
}
return shash(result);
}
function shash(s) {
var hash = 0, i, char;
if (s.length == 0) return hash;
for (i = 0; i < s.length; i++) {
char = s.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}