我无法在我的 angular 7 应用程序中显示存储在我的 firebase 存储中的图像。如何在不使用服务和从组件中存储的根目录中简单检索图像然后在 html 中循环的情况下执行此操作。
我已经尝试了不同的方法来获取下载 URL,但它们不起作用。其他方法需要使用我不想在这种情况下使用的服务。
成分
import { Component, OnInit } from '@angular/core';
import { AngularFireStorage, AngularFireStorageReference } from '@angular/fire/storage';
import { Observable } from 'rxjs'
@Component({
selector: 'app-imageviewer',
templateUrl: './imageviewer.component.html',
styleUrls: ['./imageviewer.component.css']
})
export class ImageviewerComponent implements OnInit {
images: Observable<any[]>;
constructor(private storage: AngularFireStorage) {
storage.ref("/").getDownloadURL().subscribe(downloadURL => {
this.images = downloadURL;
});
}
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="gal-list-view">
<div style="margin: 20px">
<div class="responsive" style="margin: 20px">
<div class="gallery" *ngFor="let image of images | async">
<a target="_blank"> …Run Code Online (Sandbox Code Playgroud) 我已经查看了有关 Angular 材质日期选择器的文档,但无法更改输出。我在 stackoverflow 上使用了一些答案,但它们仍然只改变了显示的格式。正如您在图片中看到的,我无法将日期选择器输出从 Mon Feb 11 更改为日期选择器输入字段 11-02-2019 example中的格式。如何让它输出日期选择器输入行上显示的格式而不是 2 月 11 日星期一并删除附加的时间值。
到目前为止,这是我的 component.ts:
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {DateAdapter,NativeDateAdapter,MAT_DATE_FORMATS,MAT_DATE_LOCALE} from "@angular/material/core";
import * as moment from "moment";
import { DatabaseService } from 'src/app/database.service'
import { Observable } from 'rxjs';
const CUSTOM_DATE_FORMATS = {parse: {dateInput: { month: "short", year: "numeric", day: "numeric" }},
display: {
dateInput: "input",
monthYearLabel: { year: "numeric", month: "short" },
dateA11yLabel: { year: "numeric", month: "long", …Run Code Online (Sandbox Code Playgroud)