As another solution I have tried to take away the need of using the 
angular.element by making a directive but it does not seem to return a 
value to the model.

Any ideas why the modelValue doesn't return any value?

<input type="file" id="fileInput" multiple ng-model="imagefile" file-feed/>

.directive('fileFeed', [
        function() {
            return {
                restrict: 'A',
                require: 'ngModel',
                link: function(scope, element, attributes, controller) {
                    element.bind("change", function(changeEvent) {
                        //alert("fired");
                        //alert(element[0].files.length);
                        var files = [];
                        for (var i = 0; i < element[0].files.length; i++) {
                            alert(element[0].files[i].name);
                            files.push(element[0].files[i]);
                        }
                        scope.$apply(function(){
                            controller.$modelValue = files;
                            
                            console.log(controller.$modelValue[0].name);
                        });
                    });
                }
            };
        }
    ]);



On Saturday, 30 May 2015 08:45:59 UTC+1, Thomas Kennedy wrote:
>
> Hi Sander,
>
> I did it with a ten second delay but nothing worked. The timeout function 
> works as the console prints out here but yet again the handlefileselect 
> never gets executed
>
>     $timeout(function() {
>         console.log("Here");
>         angular.element(document.querySelector('#fileInput')).on('change', 
> handleFileSelect);
>     },10000);
>
> On Saturday, 30 May 2015 04:59:18 UTC+1, Sander Elias wrote:
>>
>> Hi Thomas,
>>
>> use a $timeout to execute your init in the next digest round. The view 
>> will be ready by then, so you can attach your jQuery thingie then.
>>
>> Regards
>> Sander 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to