-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature/drop target as element #104
Conversation
…ow call the binded function with an additional third parameter "element" which holds the html-element on which the file was dropped. Added the parameter to the README.md. Translation required!
…loader will do nothing instead of setting properties on the dataTranser-Object
…g contains while chrome and opera are using indexOf)
Access to html elements in controller is bad practice. Options that are described here will be interpreted as setting. Another options you can use like this <input type="file" ng-file-select="{ id: 'your_id', ... }" />
or
<div ng-file-drop="{ id: 'your_id', ... }"></div> uploader.bind('afteraddingfile', function(event, item) {
// item.id
}); |
So I can do something like this: |
No, because
Why do you need html element in angular controller? |
I dont need the element. I need access to the $scope of the element. Accessing the scope of an element in the controller is no bad practice at all (imo^^). Dropping something in any system implies the knowledge about WHAT was dropped and WHERE was it droped. I can imagine lots of applications where the "WHERE" is critical (starting with filesystems also on websites). When you drop something you often need the location where it was dropped. In HTML it means you need the element. There is no other choice to access the $scope of the element but with the element itself. And thats why I need the element - yes - in my controller PS: As you may have already realized: I am coding a webapp with a fileTree. Uploading files via drag and drop into a specific directory would be a nice feature. But its only possible when you have access to the scope the file was dropped on |
for example .controller('DataController', function($scope) {
var model = $scope.model = {
data: [3, 4]
};
})
.controller('UploadController', function($scope, $fileUploader) {
var uploader = $scope.uploader = $fileUploader.create({
scope: $scope
});
uploader.bind('afteraddingfile', function(event, item) {
console.info('After adding a file', item, item.id);
});
}) <div ng-controller="UploadController">
<h3>Test</h3>
<ul>
<li ng-repeat="item in uploader.queue">Id: {{ item.id }}</li>
</ul>
<div ng-controller="DataController">
Id: 3 <input type="file" ng-file-select="{id: model.data[0]}"><br/>
Id: 4 <input type="file" ng-file-select="{id: model.data[1]}">
</div>
</div> |
Well - we are talking about dropping files and your examples are always about selecting files. Imagine you have one element with ng-drop Now imagine multiple fields Done with that we now do it a bit more tricky with ng-repeat:
Still works - we have the ids. But now we have a server generated recursive list like:
Imagine a List recursively created with this JSON Well - we could use the names as id but there could be nodes with the same name. Since ng-repeat creates a new scope every time and ng-incude does so too (we need that cause of the recursive stuff), we also cant use the controller-scope. Note that all my issues are real problems and not only "could happen"-Problems. So other user may have the same problems |
Well - I didnt know why you wrote this:
Cause it's working. This leads the discussion to absurdity. Thats why this PR can be refused cause this problem is solved. PS: Is it possible to only pull specific commits from a PR? Since my last 2 requests are more related to the emptyFiles issue (#105) |
You can fork this project and modify it. |
Are you kinda angry or annoyed about me? Sorry - I didnt want to attack you. I appreciate your work and I love this uploader. This is just a discussion. Your example wasnt solving the problem. At least I thought that. Just entering I dont know if you read the whole text. I will do another PR related to another problem (which is no rubbish this time - for sure) |
This feature extends the events afteraddingfile, whenaddingfilefailed and afteraddingall with the element on which the file was dropped provided as third argument to the listener.
Furthermore it adds a check whether the drag is a filedrag. If not the fileuploader wont do anything