import { Component, OnInit,Output, EventEmitter } 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
  }


  /**
   * 标签列表
   */
  tags:Array<string> = []
  addTag(){
    this.tags.push(this.userInputText)
    this.userInputText = ""
    this.onTagChange.emit(this.tags)
  }
  deleteTag(tag:string){
    let idx = this.tags.findIndex(item=>item==tag);
    this.tags.splice(idx,1);
  }
  @Output()
  onTagChange:EventEmitter<Array<string>> = new EventEmitter<Array<string>>()

  constructor() { }

  ngOnInit() {}

}