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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -