Solution 1 :

You can try this :

<form
    class="flex-list"
    [formGroup]="calculation_Input"
    (input)="input(&event)"
  
  >
    <div class="range-slider">
      <input
        id="slider3"
        name="in1"
        class="range-slider__range"
        type="range"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>

    <div class="range-slider">
      <input
        id="slider3"
        class="range-slider__range"
        type="range"
        name="in2"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>
</form>

event call :

input(e: any): void {
  if(e.target.name == "in1")
    console.log("for fist input value is : " + event.target.value)
  else console.log("for second input value is : " + event.target.value)
}

Solution 2 :

Try using [formControl] attribute on each of the inputs and then you can use valueChanges and subscribe.

<form
    class="flex-list"
    [formGroup]="calculation_Input"
  >
    <div class="range-slider">
      <input
        id="inputRangeStart"
        [formControl]="inputRangeStart"
        class="range-slider__range"
        type="range"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>

    <div class="range-slider">
      <input
        id="inputRangeEnd"
        class="range-slider__range"
        type="range"
        [formControl]="inputRangeEnd"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>
</form>

Event Call: // some.component.ts

inputRangeStart = new FormControl();
inputRangeEnd = new FormControl();

ngOnInit(): void {
 this.inputRangeStart.valueChanges.subscribe(value => this.onInput(value))
 this.inputRangeEnd.valueChanges.subscribe(value => this.onInput(value))
}
onInput(value: string){
    // do something
}

Problem :

I have two input fields and they refer to the same event.target.value object. I want to have them separatly.


  <form
    class="flex-list"
    [formGroup]="calculation_Input"
    (input)="input($event)"
  >
    <div class="range-slider">
      <input
        id="slider3"
        class="range-slider__range"
        type="range"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>

    <div class="range-slider">
      <input
        id="slider3"
        class="range-slider__range"
        type="range"
        value.equity="equity"
        min="0"
        max="500"
      />
      <span class="range-slider__value"> 0</span>
    </div>
</form>

The event.target.value refers now to both inputs and I have no clue how I can change it.

  input(e: any): void {
console.log(event.target.value)
  }

Comments

Comment posted by Raul Sauco

You could try giving them different IDs, the

Comment posted by Severin Koch

I tried unfortunatly it returns an emty object, no clue if its because of angular

Comment posted by Deepak

Two inputs work separately.. the console logs different values. What exactly you expect?

Comment posted by Severin Koch

I need to have the input function globally that it refers to all other fields.

Comment posted by Med Mahdi Maarouf

you can set a name for each input , and use event.target.name to know wich one haldle the event .

Comment posted by Med Mahdi Maarouf

example:

By