@99xt/ng2-fileupload 中文文档教程
@99xt/ng2-fileupload
[]() []()
更简单的 angular2 应用程序文件上传实现。
Installation
要安装此库,请运行:
npm install @99xt/ng2-fileupload --save
Usage
example.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ExampleComponent } from './example.component';
// Import the library
import { FileUploadModule } from '@99xt/ng2-fileupload';
@NgModule({
declarations: [
ExampleComponent
],
imports: [
BrowserModule,
FileUploadModule
],
providers: [],
bootstrap: [ ExampleComponent ]
})
export class ExampleModule { }
example.component.ts
export class ExampleComponent {
allowedTypes: any;
allowedSize: number;
multiple: boolean;
files: any;
constructor() {
this.allowedTypes = [ 'text/markdown' ];
this.allowedSize = 15; // MB
this.multiple = true;
}
onUploadFiles(evt: any) {
if (evt.error) {
throw evt.error;
}
const files = evt.files;
// You can run upload script here
}
}
example.component.html
<file-upload
[allowedTypes]="allowedTypes"
[allowedSize]="allowedSize"
[multiple]="multiple"
(onUploadFiles)="onUploadFiles($event)"
>
</file-upload>
Contributing Guide
Setting up the development environment
将存储库克隆到您的工作站
git clone git@github.com:99xt/ng2-fileupload.git
导航到项目目录
cd ng2-fileupload
安装并构建库
生成所有
*.js
,*.d.ts
文件
npm install
npm run build
你可以在 dist/
中找到编译后的版本
从 dist
目录创建一个符号链接到全局 node_modules
cd dist
npm link
要检查所有 *.ts
文件:
$ npm run lint
Run Demo app
cd demo
npm install
npm start
Publish to NPM
更新 package.json
和 src/package.json
中的版本;
npm run build
npm publish dist
License
麻省理工学院
@99xt/ng2-fileupload
[]() []()
Simpler file upload implementation for angular2 apps.
Installation
To install this library, run:
npm install @99xt/ng2-fileupload --save
Usage
example.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ExampleComponent } from './example.component';
// Import the library
import { FileUploadModule } from '@99xt/ng2-fileupload';
@NgModule({
declarations: [
ExampleComponent
],
imports: [
BrowserModule,
FileUploadModule
],
providers: [],
bootstrap: [ ExampleComponent ]
})
export class ExampleModule { }
example.component.ts
export class ExampleComponent {
allowedTypes: any;
allowedSize: number;
multiple: boolean;
files: any;
constructor() {
this.allowedTypes = [ 'text/markdown' ];
this.allowedSize = 15; // MB
this.multiple = true;
}
onUploadFiles(evt: any) {
if (evt.error) {
throw evt.error;
}
const files = evt.files;
// You can run upload script here
}
}
example.component.html
<file-upload
[allowedTypes]="allowedTypes"
[allowedSize]="allowedSize"
[multiple]="multiple"
(onUploadFiles)="onUploadFiles($event)"
>
</file-upload>
Contributing Guide
Setting up the development environment
Clone the repository to your workstation
git clone git@github.com:99xt/ng2-fileupload.git
Navigate to the project directory
cd ng2-fileupload
Install and build the library
Generate all
*.js
,*.d.ts
files
npm install
npm run build
You can find the compiled version in the dist/
Create a symlink from the dist
directory to the global node_modules
cd dist
npm link
To lint all *.ts
files:
$ npm run lint
Run Demo app
cd demo
npm install
npm start
Publish to NPM
Update the version in both package.json
and src/package.json
;
npm run build
npm publish dist
License
MIT