angi-file

angi-file is a directive for angularjs to help you make a model for input file and validate for supported file formats.

Version

1.0.0

Features

Installation

npm install angi-file

OR

bower install angi-file

DEMO

Click Here to see running demo.

Get the code

Usages

<script src="node_modules/angi-file/dist/angi-file.min.js"></script>

OR

<script src="bower_component/angi-file/dist/angi-file.min.js"></script>
angular.module ("net.sgoyal.sample",['net.sgoyal.angi-file'])
<input multiple formats="jpg,png" type="file" ng-model="form.file" required name="file" class="form-control">

You will get your file object in your controller scope. Enjoy!!!

(function () {
    angular.module ("net.sgoyal.sample")
    .controller ("AppCtrl", function ($scope) {
        $scope.form = {};
        //form submit handler
        $scope.saveUser = function (userform) {
            console.log ($scope.form.file);
            if (userform.$valid)
                alert ("Form saved");// will only be called if user have selected valid formats that you have configured.
        };
    });
})();

Attributes

Contribute

Do you want to improve it? Sounds cool. Please drop me a line at mail.goyalshubham@gmail.com