Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add on file changed directive #293

Closed
robmcguinness opened this issue Jan 11, 2018 · 0 comments
Closed

add on file changed directive #293

robmcguinness opened this issue Jan 11, 2018 · 0 comments

Comments

@robmcguinness
Copy link
Contributor

robmcguinness commented Jan 11, 2018

const fileChange = {
  restrict: 'A',
  link(scope, element, attrs) {
    // clean up bind on scope destroy  
    element.bind('change', () => {
      scope.$applyAsync(() => {
        const onFileChangeHandler = scope.$eval(attrs.onFileChange);
        const el = element[0];

        if (el.files) {
          onFileChangeHandler(el);
        }
      });
    });
  },
};

export default function() {
  return fileChange;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant