File

upload/src/upload.service.ts

Description

Upload service provides access to files selected in Upload component and allows to remove files or change their upload state.

Example :
@Component({
  template: `<talenra-upload />`,
  imports: [UploadComponent],
  providers: [{ provide: UploadService, useClass: UploadService }]
  ...
})
export class ConfigurableUploadComponent {
  private uploadService: UploadService = inject(UploadService);
  ...
}

Import

Example :
import { UploadService } from '@talenra/components/upload';

See UploadComponent See IUploadItem See UploadState

../../../#/upload

Index

Properties
Methods

Methods

Public removeItem
removeItem(identifier: string)

Remove file with given identifier.

Example :
this.uploadService.removeItem('161ae2d1-e33c-4648-99a4-c3d568131d45');
Parameters :
Name Type Optional
identifier string No
Returns : void
Public setUploadState
setUploadState(identifier: string, state: TUploadState)

Set upload state of file with given identifier

Example :
this.uploadService.setUploadState('161ae2d1-e33c-4648-99a4-c3d568131d45', UploadState.Uploaded);

See UploadState

Parameters :
Name Type Optional
identifier string No
state TUploadState No
Returns : void

Properties

Public Readonly items
Type : unknown
Default value : this._items.asReadonly()

Array of currently selected items in Upload component.

Example :
const items: IUploadItem[] = this.uploadService.items();

See IUploadItem

Public Readonly validItems
Type : unknown
Default value : computed<IUploadItem[]>(() => this._items().filter((item) => item.validationState === UploadValidationState.Valid) )

Array of currently selected valid items in Upload component.

Example :
const validItems: IUploadItem[] = this.uploadService.validItems();

See IUploadItem

results matching ""

    No results matching ""