npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mhernandez-easygo/ngx-input-file

v13.0.0

Published

Angular Input File Component

Downloads

3

Readme

ngx-input-file

ngx-input-file is a module to replace the html element input file with Material Design.

Try it with Stackblitz!

For the previous version with bootstrap: [email protected].

Key features

  • Preview of the file
  • Drag and drop zone
  • Responsive

Installation

npm install ngx-input-file --save

Basic Configuration

import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { InputFileConfig, InputFileModule } from 'ngx-input-file';

const config: InputFileConfig = {};

@NgModule({
    imports: [
        ...
        BrowserAnimationsModule,
        InputFileModule.forRoot(config),
        ...
    ],
    ...
})

export class MyModule {}

Please include material-design-icons in your angular.json:

"styles": [
    "node_modules/material-design-icons/iconfont/material-icons.css",
    "src/styles.scss"
]

Component Attributes

These settings will overide the configuration defined with forRoot() method.

| Attribute | Type | Description | | ----------------------- |:-----------------------:| :---------------------------------------- | | fileAccept | Input - string | The attribute accept of the html element input. | | fileLimit | Input - number | The maximum files that the user can upload. | | iconAdd | Input - string | The icon for add. | | iconDelete | Input - string | The icon for delete. | | iconFile | Input - string | The icon for file. | | iconLink | Input - string | The icon for link. | | linkEnabled | Input - boolean | Whether adding is url is enabled. | | placeholderLink | Input - string | The placeholder for the link input. | | sizeLimit | Input - number | The maximum size of the file (kB). | | disabled | Input - boolean | Whether the component is disabled. | | placeholder | Input - string | The placeholder of the component. | | classAnimation | Input - string | The class of the image container which allow to animate the container when select or drop a file. | | ngModel/formControlname | Array | Template driven or reactive form works. | acceptedFile | Output - InputFile | Triggered when a file is accepted. | | deletedFile | Output - InputFile | Triggered when a file is deleted. | | rejectedFile | Output - InputFile | Triggered when a file is rejected. |

Configuration Attributes

| Attribute | Type | Default | Description | | ----------------------- |:----------: |:-------------:| :---------------------------------------- | | classAnimation | string | 'bounce-in' | The class of the image container which allow to animate the container when select or drop a file. | | fileAccept | string | '*' | The attribute accept of the html element input. | | fileLimit | number | 1 | The maximum files that the user can upload. | | iconAdd | string | 'add' | The icon for add. | | iconDelete | string | 'delete' | The icon for add. | | iconFile | string | 'insert_drive_file' | The icon for file. | | iconLink | string | 'link' | The icon for link. | | linkEnabled | boolean | false | Whether adding is url is enabled. | | placeholderLink | string | 'Link' | The placeholder for the link input. | | sizeLimit | number | null | The maximum size of the file (kB). |

Example

<input-file
    placeholder="My files"
    [(ngModel)]="myModel">
</input-file>

<input-file
    placeholder="Pictures"
    formControlName="myField">
</input-file> 

Bonus

Here's an example to post a file:

import { HttpClient } from '@angular/common/http';

@Injectable()
export class MyRepository {

constructor(
    private http: HttpClient
) {}

public post(file: InputFile): Observable<YourClass> {
    const apiUrl = 'my-url';
    const formData = new FormData();
    formData.append('file', file.file, file.file.name);
    return this.http.post<YourClass>(apiUrl, formData).pipe(
        .catchError(...)
}

For developpers

You're welcome, please fork this repository to a make pull request.

Demonstration

Clone this repository and run npm start.