Git Product home page Git Product logo

ngx-file-drag-drop's Introduction

ngx-file-drag-drop

Check out the Demo

Install

npm i ngx-file-drag-drop

API reference

NgxFileDragDropModule

import { NgxFileDragDropModule } from 'ngx-file-drag-drop';

@NgModule({
  imports: [
    // the module for this lib
    NgxFileDragDropModule
  ]
})

NgxFileDragDropComponent

selector: <ngx-file-drag-drop>

implements: ControlValueAccessor to work with angular forms

Additionnal properties

Name Description
@Input() multiple: boolean Allows multiple file inputs, false by default
@Input() accept: string Any value the native accept attribute can get. Doesn't validate input.
@Input() disabled: boolean Disable the input.
@Input() emptyPlaceholder : string Placeholder for empty input, default Drop file or click to select
@Input() displayFileSize : boolean Show file size in chip rather than in tooltip, default false
@Input() activeBorderColor: string A css color for when file is dragged into drop area, default purple
@Output() valueChanged:EventEmitter<File[]> Event emitted when input value changes
addFiles():(files: File[] | FileList | File) => void Update input
removeFile():(file:File) => void Removes the file from the input
clear(): () => void Removes all files from the input
files: File[] Getter for form value
isEmpty: boolean Whether the input is empty (no files) or not

BytePipe

Usage:

<span>{{ 104857600 | byteFormat }}</span>

Output: 100 MB

Validators

import { FileValidators } from "ngx-file-drag-drop";
Validator Description
uniqueFileNames Disallow two files with same file name
fileExtension(ext: string[]) Required file extensions
fileType(types: string[] | RegExp) Required Mime Types
maxFileCount(count: number) Max number of files
maxFileSize(bytes: number) Max bytes allowed per file
maxTotalSize(bytes: number) Max total input size
required At least one file required

ngx-file-drag-drop's People

Contributors

meblum avatar shimonsalamon avatar jakehockey10 avatar ksantacr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.