[英]How to set more than one Angular2 var in Jquery onchange
I am unable to assign more than one var in jquery in Angular2. 我无法在Angular2的jquery中分配多个var。
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: 这是完美的工作,但我想将索引[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]
);
But at this time I am this.selected_text is set but not this.updateForm.value.sources . 但是这时我设置了this.selected_text,但是没有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];
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.