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

@ahmedtamseer/tn-file-upload

v1.0.1

Published

Angular package for to customize input type file in both reactive and template driven forms

Downloads

5

Readme

TnFileUpload

The Angular library for input type file.

ng add @ahmedtamseer/tn-file-upload

What is TnFileUpload?

TnFileUpload is angular package for form element (input:file). This package gives new look and good user experience both reactive and template driven forms. This package can return both type File or Base64 value.

Quickstart

1. Create a new project

npm install -g @angular/cli
ng new <project-name>
cd <project-name>

The Angular CLI's new command will set up the latest Angular build in a new project structure.

2. Install Angular Form Error

ng add @ahmedtamseer/tn-file-upload

Now that you have a new project setup, install Angular Form Error from npm.

3. Setup @NgModule for the TnFileUploadModule

Open /src/app/app.module.ts, inject the TnFileUploadModule.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { TnFileUploadModule } from '@ahmedtamseer/tn-file-upload';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    ReactiveFormsModule,
    FormsModule,
    TnFileUploadModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

4. Use it in your component

import { Component } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';

@Component({
  selector: 'app-root',
  template: `
  <form [formGroup]="demoForm">
    <div>
        <label for="file">File</label>
         <tn-file-upload [(ngModel)]="ngModalExample" #name="ngModel"></tn-file-upload>
    </div>
  </form>
  `
})
export class MyApp {

  demoForm: FormGroup;

  constructor() {
      this.demoForm = new FormGroup({
      file: new FormControl('')
    });
  }
}

5. Run your app locally

ng serve

Resources

Stackblitz Template - A demo app which shows how to use package for Reactive and Template Driven form.

Developer Guide

| attribute | purpose | | ---------|--------------------| | [multiple] | Boolean. A Boolean which, if present, indicates that the user may choose more than one file. Default false | | [maxFileCount] | Number. Maximum number of files a user can select. This applies only when [multiple]="true". Default 10 | | [restrictSize] | Number. Maximum size of file/s. This value is in MB. Default 5 | | [accept] | String. One or more unique file type specifiers describing file types to allow. KnowMore Default */* | | [displayFile] | Boolean. Whether or not to display (preview) file after selection. Default true | | [displayName] | Boolean. Whether or not to display file name after selection. Default true | | [displaySize] | Boolean. Whether or not to display file size after selection. Default true | | [showCustomRemoveButton] | Boolean. Whether or not allow user to remove a file. Default true | | [hidden] | Boolean. This hides input element. Default false | | [isDisabled] | Boolean. Disabled property of html. Default false | | [base64] | Boolean. Setting this to true will return base64 value along with original file. Default false | | [class] | String. List of classes separated by space. Ex:- [class]="'bg-danger text-white'" |

Base64 return value

{
  url: string;
  name?: string;
  size?: number;
  status?: string;
  type?: string;
  ext?: string;
  preExt?: string;
  file?: File
}