angular - get value of slider with (change) of particular slider while using multiple sliders -


i have multiple slider in component , i'm using nouislider

<nouislider [connect]="true"  [(ngmodel)]="somevalue"  [config]="somekeyboardconfig" (change)="saverange($event)"></nouislider>  <nouislider [connect]="true"   [(ngmodel)]="somevalue1"  [config]="somekeyboardconfig" (change)="saverange($event)"></nouislider> 

component.ts

saverange(value) {     console.log('value changed to', value);   } 

i value on (change)` don't know slider value have 7 slider in 1 page. how know sliders value is. after getting slider range want write in json file

please suggest me way here.

you have multiple options here:

1. pass attribute method along event. following:

html:

<nouislider [connect]="true"  [(ngmodel)]="somevalue"  [config]="somekeyboardconfig" (change)="saverange('first', $event)">      </nouislider>  <nouislider [connect]="true"   [(ngmodel)]="somevalue1"  [config]="somekeyboardconfig" (change)="saverange('second', $event)">     </nouislider> 

js/ts

saverange(slider, value) {    console.log('value of ' + slider + ' slider changed to', value); } 

2. use 2 methods

html:

<nouislider [connect]="true"  [(ngmodel)]="somevalue"  [config]="somekeyboardconfig" (change)="savesecondrange($event)">      </nouislider>  <nouislider [connect]="true"   [(ngmodel)]="somevalue1"  [config]="somekeyboardconfig" (change)="savefirstrange($event)">     </nouislider> 

js/ts

savefirstrange(value) {    console.log('value of first slider changed to', value); } savesecondrange(value) {    console.log('value of second slider changed to', value); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -