<ejs-uploader #defaultupload [autoUpload]='false' [asyncSettings]='path' [locale]='locale'></ejs-uploader> |
import { Component } from '@angular/core';
import { detach, L10n } from '@syncfusion/ej2-base';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
// Define the Save and remove URL for upload and remove action
public path = {
saveUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save',
removeUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove'
{color:#ff991f}};
// Define the locale.
locale= 'fr-CH';
ngOnInit() {
// Customize the Uploader names with corresponding locale.
L10n.load({
"fr-CH": {
"uploader": {
"invalidMinFileSize": "La taille du fichier est trop petite! S'il vous plaît télécharger des fichiers avec une taille minimale de 10 Ko",
"invalidMaxFileSize": "La taille du fichier dépasse 28 Mo",
"invalidFileType": "Le type de fichier n'est pas autorisé",
"Browse": "Feuilleter",
"Clear": "Clair",
"Upload": "Télécharger",
"dropFilesHint": "ou Déposer des fichiers ici",
"uploadFailedMessage": "Impossible d'importer le fichier",
"uploadSuccessMessage": "Fichier téléchargé avec succès",
"removedSuccessMessage": "Fichier supprimé avec succès",
"removedFailedMessage": "Le fichier n'a pas pu être supprimé",
"inProgress": "Téléchargement",
"readyToUploadMessage": "Prêt à télécharger",
"remove": "Retirer",
"cancel": "Annuler",
"delete": "Supprimer le fichier"
}
}
})
} |
<ejs-uploader #defaultupload id='defaultfileupload' [asyncSettings]='path' [autoUpload]='false' [dropArea]='dropElement' (removing)='onFileRemove($event)' [buttons]='buttons'></ejs-uploader> |
import { Component, ViewChild, ViewEncapsulation, Inject } from '@angular/core';
import { createElement } from '@syncfusion/ej2-base';
import { UploaderComponent, RemovingEventArgs } from '@syncfusion/ej2-angular-inputs';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild('defaultupload')
public uploadObj: UploaderComponent;
public path: Object = {
saveUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save',
removeUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove'
};
public dropElement: HTMLElement = document.getElementsByClassName('control-fluid')[0] as HTMLElement;
public onFileRemove(args: RemovingEventArgs): void {
args.postRawFile = false;
}
public uploadEle: HTMLElement = createElement('span', { className: 'upload e-icons', innerHTML: 'Upload All' });
public buttons: Object = {
browse: 'Choose file',
// Assign the external button to upload button
upload: this.uploadEle
{color:#ff991f}};
ngAfterViewInit() {
// Store the uploader instnce in the variable
var Uploader = this.uploadObj;
(this.uploadEle).addEventListener('click', function (e) {
// Call source upload method to perform upload action
(Uploader as any).uploadButtonClick();
{color:#ff991f}});
}
} |