简体   繁体   中英

How to set more than one Angular2 var in Jquery onchange

I am unable to assign more than one var in jquery in Angular2.

what I am doing is:

jQuery('.source-select').on('change',(e) => this.updateForm.value.sources = jQuery(e.target).val().split('--')[0]);

this is working prefectly but I want to assigned splited value of index [1] to another object as:

  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]
   );

But at this time I am this.selected_text is set but not this.updateForm.value.sources . Any guess what I am doing wrong.

*** I tried using on change twice and that is working fine but I dont think its good to do that.

I don't know if I really understand your question but why don't you use it ike this?

 jQuery('.source-select').on('change',function(e){
    this.updateForm.value.sources = jQuery(e.target).val().split('--')[0];       
    this.selected_text = jQuery(e.target).val().split('--')[1];        
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM