angularjs - ngModel Not Updating In Directive -


i have directive detects change of file input , aims set model. imagefile model not being set after file change. have been able print out values of controller.modelvalue[0].name , set. when returns image file model null.

any suggestions on how fix or doing incorrect?

the html code here

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

the directive file-feed attribute

.directive('filefeed', [         function() {             return {                 restrict: 'a',                 require: 'ngmodel',                 link: function(scope, element, attributes, controller) {                     element.bind("change", function(changeevent) {                         //alert("fired");                         var files = [];                         (var = 0; < element[0].files.length; i++) {                             //alert(element[0].files[i].name);                             files.push(element[0].files[i]);                         }                          controller.$modelvalue = files;                          scope.$apply(function(){                             **controller.$modelvalue = files;**                             console.log(controller.$modelvalue[0].name);                         });                     });                 }             };         }     ]); 

the modal controller here

.controller('profilepicturemodalinstancectrl', function ($scope, $modalinstance, items, $timeout) {      $scope.imagefile = "";      $scope.checkimagefiles = function(){         console.log($scope.imagefile);     }      $scope.ok = function () {         $modalinstance.close($scope.optionitems);     };      $scope.cancel = function () {         $modalinstance.dismiss('cancel');     }; }) 

i have button in modal calls function in controller print out value of image file.

<button ng-click="checkimagefiles()">check images</button> 

i trying return file via controller.modelvalue property


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -