import { Component, Output, EventEmitter, Input, OnInit } from '@angular/core'; import { showAlert } from 'src/app/const/alert'; import { ApiChatService } from 'src/app/services/api-chat.service'; import * as vars from "../../const/api" @Component({ selector: 'app-send-form', templateUrl: './send-form.component.html', styleUrls: ['./send-form.component.css'] }) export class SendFormComponent implements OnInit { @Input() board: string; showForm:boolean = false; // inputText: string; inputImages: string[] = []; @Output() sendInfoToCreate = new EventEmitter(); constructor( public apiChatService: ApiChatService) { } create(text:string){ var toSend = { text: text, images: this.inputImages } this.sendInfoToCreate.emit(toSend) toSend.text = ''; toSend.images = []; } sendPic(event: any) { this.apiChatService.sendpic(event.target.files[0]).subscribe( response => { response = response.value.toString(); this.inputImages.push(response); showAlert(`Картинка ${response} добавлена`, "#ff0a36") }); } ngOnInit(): void { } }