Directive to get files input with ng-model [duplicate]

与世无争的帅哥 提交于 2019-11-27 16:28:15

ngModel directive is not usable on file input.

If you don't care about being in debugInfoEnabled on prod, you can pass it true like this in your app.js.

$compileProvider.debugInfoEnabled(true);

You then will be able to access your scope from your html. In you file input just add :

onchange="angular.element(this).scope().yourChangeFunction(this)

You can access your file in your js code with :

scope.yourChangeFunction = function(element){scope.file=element.files[0];}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!