html - ng-model not working with file input -


i'm trying value of file input , display somewhere else, outside of input. i'm using angularjs v1.4.8 in app.

<input type="file" ng-model="filename" /> <div>{{filename}}</div> 

this approach works fine type="text" not type="file".

why , how can solve problem?

thank you!

since task pretty straightforward, decided go way:

html:

 <input type="file" file-input="files" />  <ul>      <li ng-repeat="file in files">{{file.name}}</li>  </ul> 

js:

.directive('fileinput', ['$parse', function ($parse) {     return {         restrict: 'a',         link: function (scope, element, attributes) {             element.bind('change', function () {                 $parse(attributes.fileinput)                 .assign(scope,element[0].files)                 scope.$apply()             });         }     }; }]); 

this solution this tutorial. note can work multiple files.

nevertheless there nothing bad serghinho's alternative, there easier way, think.


Comments

Popular posts from this blog

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

matplotlib - PYTHON: Annotate boxes disapear dependant on range -