Skip to content

Instantly share code, notes, and snippets.

@oliverm2112
Last active December 25, 2015 02:29
Show Gist options
  • Save oliverm2112/6902756 to your computer and use it in GitHub Desktop.
Save oliverm2112/6902756 to your computer and use it in GitHub Desktop.
form test JS
app = angular.module('MyApp', []);
app.controller('MyCtrl', ['$scope', function ($scope) {
$scope.model = {
test : 'hello'
};
$scope.submitForm = function () {
alert('Dirty: ' + $scope.theForm.$dirty);
theForm.submit();
};
$scope.$watch('theForm.$dirty', function (newVal, oldVal) {
if (newVal !== oldVal) {
console.log('changed', oldVal, newVal);
}
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment