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

ngf-change gets called as soon as button is clicked #762

Closed
lookfirst opened this issue May 25, 2015 · 8 comments
Closed

ngf-change gets called as soon as button is clicked #762

lookfirst opened this issue May 25, 2015 · 8 comments

Comments

@lookfirst
Copy link
Contributor

The documentation suggests that ngf-change would be called after the files are selected in the chooser dialog. Right now, it gets called as soon as the button is clicked.

@deckikwok
Copy link

You are right though I wont say it's an error. I believe if your model did not specify null initially then a 'change' would have been detected. For now, you can do an if (file && file.length)

@danialfarid
Copy link
Owner

Updated the wordings in the doc.

@lookfirst
Copy link
Contributor Author

Please re-open. This can't possibly be the intended behavior. Not only does it fire before the file chooser opens, but also after.

@danialfarid
Copy link
Owner

Yea I explained it in the docs, it will be called when the files selected or cleared by clicking on the button.

@lookfirst
Copy link
Contributor Author

@danialfarid What I'm seeing is that ngf-change is being called TWICE. Once when you click the button and the file chooser dialog opens and once when the dialog closes after selecting a file.

I added this to your fiddle...

    $scope.upload = function (files) {
        alert('called from upload. files is: ' + files);

Whatever is calling it shouldn't call it the first time. There is no reason to call $scope.upload if files is null. This would allow me to remove the null check and simplify things greatly.

@danialfarid
Copy link
Owner

I explained on my first comment why it needs to be set to null when you click on it. So it is expected behaviour.

@lookfirst
Copy link
Contributor Author

It doesn't need to fire.

@danialfarid
Copy link
Owner

#764

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

3 participants