File

projects/rebirth-ng/src/lib/file-upload/file-upload-preview.component.ts

Metadata

changeDetection ChangeDetectionStrategy.OnPush
exportAs fileUploadPreview
selector re-file-upload-preview
templateUrl ./file-upload-preview.component.html

Index

Methods
Inputs
Outputs

Inputs

disabled

Type: boolean

imgPreview

Type: boolean

previewWidth

Type: string

selectFiles

Type: SelectFileModel[]

Default value: []

uploaded

Type: boolean

Outputs

removeFile $event type: EventEmitter

Methods

onRemoveFile
onRemoveFile(fileItem: )
Parameters :
Name Optional
fileItem no
Returns : void
import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
import { SelectFileModel } from './file-upload.model';

@Component({
  selector: 're-file-upload-preview',
  templateUrl: './file-upload-preview.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  exportAs: 'fileUploadPreview'
})
export class FileUploadPreviewComponent {

  @Input() imgPreview: boolean;
  @Input() previewWidth: string;
  @Input() uploaded: boolean;
  @Input() disabled: boolean;
  @Input() selectFiles: SelectFileModel[] = [];
  @Output() removeFile = new EventEmitter<SelectFileModel>();

  onRemoveFile(fileItem) {
    if (!this.disabled) {
      this.removeFile.emit(fileItem);
    }
  }
}
<div class="file-upload-preview">
  <table class="table">
    <tbody>
    <tr *ngFor="let fileItem of selectFiles">
      <td *ngIf="imgPreview">
        <a [href]="fileItem.url" target="_blank">
          <img *ngIf="fileItem.url" class="img-responsive" [src]="fileItem.url"
               [attr.alt]="fileItem.name"
               [style.width]="previewWidth"/>
        </a>
      </td>
      <td>
        <i *ngIf="uploaded" class="glyphicon glyphicon-ok text-success"></i> {{fileItem.name}}
      </td>
      <td>
        {{fileItem.displaySize}}
      </td>
      <td>
        <i class="glyphicon glyphicon-trash text-danger" [ngClass]="{disabled: disabled}"
           (click)="onRemoveFile(fileItem)"></i>
      </td>
    </tr>
    </tbody>
  </table>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""