list file attachments
This commit is contained in:
@@ -1 +1,3 @@
|
||||
<p>file works!</p>
|
||||
<a [href]="url$|async" target="_blank">
|
||||
{{name}}
|
||||
</a>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {File} from '../../../../services/file';
|
||||
import {AngularFireStorage} from '@angular/fire/storage';
|
||||
|
||||
@Component({
|
||||
selector: 'app-file',
|
||||
@@ -6,11 +9,20 @@ import {Component, OnInit} from '@angular/core';
|
||||
styleUrls: ['./file.component.less']
|
||||
})
|
||||
export class FileComponent implements OnInit {
|
||||
public url$: Observable<string>;
|
||||
public name: string;
|
||||
|
||||
constructor() {
|
||||
constructor(private storage: AngularFireStorage) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
@Input() set file(file: File) {
|
||||
|
||||
const ref = this.storage.ref(file.path + '/' + file.name);
|
||||
this.url$ = ref.getDownloadURL();
|
||||
this.name = file.name;
|
||||
|
||||
};
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user