angularjs-file-model

AngularJS directive to support NgModel for HTML input file types

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
20Jun 1, 2021Jul 16, 2018Minified + gzip package size for angularjs-file-model in KB

Readme

angularjs-file-model Tests

AngularJS directive to support NgModel for HTML input file types

Getting Started

Installation

You can directly clone/download here

git clone https://github.com/sibiraj-s/angularjs-file-model.git

or use cdn

Minified:

//unpkg.com/angularjs-file-model@latest/fileModel.min.js

Pretty Printed:

//unpkg.com/angularjs-file-model@latest/fileModel.js

or

Install via Package managers such as npm or yarn

npm install angularjs-file-model --save
# or
yarn add angularjs-file-model

Usage

Import the modules required for angularjs-file-model.

<script src="angular/angular.min.js"></script>
<script src="../fileModel.min.js"></script>

add angularjsFileModel dependency to the module

angular.module('myApp', ['angularjsFileModel'])

and in your html

<input type="file" ng-model="files" file-model ng-change="onFileSelect()">

or

<input type="file" ng-model="files" file-model as-file ng-change="onFileSelect()">

Option

as-file will bind the file object to the ng-model without it only plain object with file properties will bind to ng-model

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.