I'm developing an app with Angular 2.0, and I don't know how to listen to an input range changes.
Here's the component:
import { Component } from '@angular/core';
@Component({
selector: 'zoom-slider',
styleUrls: [
'./zoom-slider.style.scss'
],
template: `
<div class="zoom-slider">
<input type="range" max="5" (click)="changeZoom"/>
</div>
`
})
export class ZoomSlider {
changeZoom() {
console.log('change slider');
}
}
This doesn't work.
Thanks in advance!
When we enter tags one character at a time, Angular performs change detection after every character is entered. So, if we type in “foo”, the Angular binding records for the <input> element value attribute will follow this sequence: "" , "f" , "fo" , "foo" .
<input type="range"> <input> elements of type range let the user specify a numeric value which must be no less than a given value, and no more than another given value. The precise value, however, is not considered important.
Angular Bootstrap 5 Range component A Range is an interactive component that lets the user swiftly slide through possible values spread over the desired range. Note: Read the API tab to find all available options and advanced customization.
You need to listen for the change event and have a reference to the input.
<input type="range" #ref (change)="changeZoom(ref.value)"/>
changeZoom(value: number) { ... }
I guess one of these should work
<input type="range" max="5" (input)="changeZoom($event)"/>
<input type="range" max="5" (change)="changeZoom($event)"/>
If you pass the function as above (click)
might work as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With