import { Component, EventEmitter, OnInit,Output } from '@angular/core';
import { IonInput,IonButton,IonChip } from '@ionic/angular/standalone';

@Component({
  selector: 'app-edit-tag',
  templateUrl: './edit-tag.component.html',
  styleUrls: ['./edit-tag.component.scss'],
  imports:[
    IonInput,IonButton,IonChip
  ],
  standalone: true,
})
export class EditTagComponent  implements OnInit {
/*
*用户输入
*/
  userInputText:String = "" 
  userInput(ev:any){
    console.log(ev);
    this.userInputText=ev.detail.value;
    this.onTagChange.emit(this.tags);
  }
  /*
  *标签列表
  */
tags:Array<String> =[]
addTag(){
  this.tags.push(this.userInputText);
  this.userInputText ="";
}
deleteTag(tag:any){
  let idx=this.tags.findIndex(item=>item==tag);
  this.tags.splice(idx,1);
}
@Output()
onTagChange:EventEmitter<Array<String>> = new EventEmitter<Array<String>>();

  constructor() { }

  ngOnInit() {}

}
