custom-on-change.js 319 B

12345678910111213
  1. app.directive('customOnChange', function() {
  2. return {
  3. restrict: 'A',
  4. link: function (scope, element, attrs) {
  5. var onChangeHandler = scope.$eval(attrs.customOnChange);
  6. element.on('change', onChangeHandler);
  7. element.on('$destroy', function() {
  8. element.off();
  9. });
  10. }
  11. };
  12. });