3838</p >
3939<h1 align =" center " >
4040 Get Started —
41- <a href =" https://stackblitz.com/edit/angular-upload-widget " >
41+ <a href =" https://stackblitz.com/edit/angular-upload-widget?file=src%2Fapp%2Fapp.component.ts " >
4242 Try on StackBlitz
4343 </a >
4444</h1 >
@@ -99,7 +99,7 @@ export class AppModule {}
9999
100100Choose one of these options:
101101
102- ### Option 1: Use the ` uploadButton ` directive
102+ ### Option 1: Create an Upload Button — [ Try on StackBlitz ] ( https://stackblitz.com/edit/angular-upload-widget?file=src%2Fapp%2Fapp.component.ts )
103103
104104The ` uploadButton ` directive displays a file upload modal on click.
105105
@@ -110,34 +110,38 @@ Inputs:
110110- ` uploadComplete ` (optional): a callback containing a single parameter — an array of uploaded files.
111111
112112``` typescript
113- import { Component } from " @angular/core" ;
114- import { Uploader , UploadWidgetConfig , UploadWidgetResult } from " uploader" ;
113+ import { Component } from ' @angular/core' ;
114+ import { Uploader , UploadWidgetConfig , UploadWidgetResult } from ' uploader' ;
115115
116116@Component ({
117- selector: " app-root" ,
117+ selector: ' app-root' ,
118118 template: `
119- <button uploadButton
120- [uploader]="uploader"
121- [uploadOptions]="options"
122- [uploadComplete]="onComplete">
119+ <a href="{{ uploadedFileUrl }}" target="_blank">{{ uploadedFileUrl }}</a>
120+ <button
121+ uploadButton
122+ [uploadComplete]="onComplete"
123+ [uploadOptions]="options"
124+ [uploader]="uploader"
125+ >
123126 Upload a file...
124127 </button>
125- `
128+ ` ,
126129})
127130export class AppComponent {
128- uploader = Uploader ({
129- apiKey: " free"
131+ uploader = Uploader ({
132+ apiKey: ' free' , // <-- Get production-ready API keys from Upload.io
130133 });
131134 options: UploadWidgetConfig = {
132- multi: false
135+ multi: false ,
133136 };
134137 onComplete = (files : UploadWidgetResult []) => {
135- alert ( files . map ( x => x .fileUrl ). join ( " \n " )) ;
138+ this . uploadedFileUrl = files [ 0 ]? .fileUrl ;
136139 };
140+ uploadedFileUrl = undefined ;
137141}
138142```
139143
140- ### Option 2: Use the ` upload-dropzone ` component
144+ ### Option 2: Create a Dropzone — [ Try on StackBlitz ] ( https://stackblitz.com/edit/angular- upload-dropzone?file=src%2Fapp%2Fapp. component.ts )
141145
142146The ` upload-dropzone ` component renders an inline drag-and-drop file uploader.
143147
0 commit comments