我有一個輸入字段,用戶可以comma在其中輸入多個輸入。<div class="container"> Enter your values:<input type="text" multiple #inputCheck> <input type="submit"(click)="sendInput(inputCheck.value)"></div>這些輸入將存儲在以下數組中。 arrayStored=[]我嘗試使用下面的代碼,但輸入沒有在數組中劃分,整個輸入被視為數組中的單個元素。我需要將輸入分成多個元素并將它們存儲在數組中。 sendInput(event:any){ this.inputGiven = event; this.arrayStored.push(this.inputGiven);示例:如果用戶輸入SAM,ALEX7,23并單擊提交,則數組應將其存儲為,arrayStored=["SAM","ALEX7,"23"]但現在將其存儲為arrayStored=["SAM,ALEX7,23"]。如何拆分輸入并將它們作為單個元素存儲在數組中?
拆分輸入數組值 - Angular
慕無忌1623718
2022-10-27 15:19:12