Giter VIP home page Giter VIP logo

mat-file-upload's Introduction

Angular Material File Upload npm Build Status

This tool is a simple & configurable file upload component for use with Angular Material.

Live Demo: https://bjsawyer.github.io/mat-file-upload/

Screen Shot 2019-04-24 at 8 40 27 PM

Prerequisites

In order to use mat-file-upload in your app, you must have the following dependencies installed:

Usage

  1. Install package from npm (npm i mat-file-upload).
  2. Add MatFileUploadModule to your module's imports, like so:
@NgModule({
  declarations: [AppComponent],
  imports: [
    ...
    MatFileUploadModule,
    ...
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
  1. Add the element to your template, like so:

Basic:

<mat-file-upload></mat-file-upload>

Advanced:

<mat-file-upload
  [labelText]="'Select a file (or multiple) to upload:'"
  [selectButtonText]="'Choose File(s)'"
  [selectFilesButtonType]="button"
  [uploadButtonText]="'Submit'"
  [uploadButtonType]="submit"
  [allowMultipleFiles]="true"
  [showUploadButton]="true"
  [customSvgIcon]="'close_custom'"
  [acceptedTypes]="'.png, .jpg, .jpeg'"
  (uploadClicked)="onUploadClicked($event)"
  (selectedFilesChanged)="onSelectedFilesChanged($event)"
>
</mat-file-upload>

Options

@Input() Properties

Directive Type Description Default Value
[labelText] string The text to be displayed for the file upload label "Select file(s)"
[selectButtonText] string The text to be displayed for the button that allows the user to select file(s) "Select file(s)"
[selectFilesButtonType] string The HTML "type" attribute of the "Select Files" button "button"
[uploadButtonText] string The text to be displayed for the button that allows the user to upload file(s) "Upload File(s)"
[uploadButtonType] string The HTML "type" attribute of the "Upload" button "button"
[allowMultipleFiles] boolean True/false representing whether the user can select multiple files at a time false
[showUploadButton] boolean True/false representing whether the "Upload" button is shown in the DOM true
[customSvgIcon] string The name of the custom svgIcon to be used as the "close" button; otherwise defaults to Material's "close" icon null
[acceptedTypes] string The list of file types that are allowed to be uploaded "*.*"

@Output() Properties

Directive Type Description
(uploadClicked) EventEmitter<FileList> Event handler that emits the list of selected files whenever the "Upload" button is clicked
(selectedFilesChanged) EventEmitter<FileList> Event handler that emits the list of selected files whenever the user changes file selection

mat-file-upload's People

Contributors

bjsawyer avatar dependabot[bot] avatar bbagdad avatar samuelmarks avatar chartchai 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.