0
我無法在Angular2的jquery中分配多個var。如何在Jquery onchange中設置多個Angular2 var
什麼我做的是:
jQuery('.source-select').on('change',(e) => this.updateForm.value.sources = jQuery(e.target).val().split('--')[0]);
這是工作prefectly但我想索引的分配splited值[1]到另一個對象爲:
jQuery('.source-select').on('change',(e) => this.updateForm.value.sources = jQuery(e.target).val().split('--')[0]
,(e) => this.selected_text = jQuery(e.target).val().split('--')[1]
);
但就在這個時候,我這this.selected_text設置,但不是this.updateForm.value.sources。任何猜測我做錯了什麼。
***我試過使用兩次,這是工作正常,但我不認爲它很好做到這一點。
我試過這個,但我得到了無法讀取updateForm.value未定義屬性'值'我認爲。 –
當您將此事件用於事件 時,此=== e.currentTarget將返回true 和 此===如果currentTarget和target相同,則e.target將返回true。也許你沒有使用你認爲「this」的值。 – Romain