All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.ng-file-model.ng-file-model.js Maven / Gradle / Ivy

(function () {
    'use strict';
    angular.module('ng-file-model', [])
        .directive("ngFileModel", [function () {
            return {
                scope: {
                    ngFileModel: "="
                },
                link: function (scope, element, attributes) {
                    element.bind("change", function (changeEvent) {
                        var reader = new FileReader();
                        reader.onload = function (loadEvent) {
                            scope.$apply(function () {
                                scope.ngFileModel = {
                                    lastModified: changeEvent.target.files[0].lastModified,
                                    lastModifiedDate: changeEvent.target.files[0].lastModifiedDate,
                                    name: changeEvent.target.files[0].name,
                                    size: changeEvent.target.files[0].size,
                                    type: changeEvent.target.files[0].type,
                                    data: loadEvent.target.result
                                };
                            });
                        }
                        reader.readAsDataURL(changeEvent.target.files[0]);
                    });
                }
            }
        }]);
    if (typeof exports !== 'undefined') {
        exports['default'] = angular.module('ng-file-model');
        module.exports = exports['default'];
    }
})();




© 2015 - 2025 Weber Informatics LLC | Privacy Policy