Angular Matrial Slider Data Binding while dragging
up vote
1
down vote
favorite
I'm trying to control the audio volume with a material slider. Just like the YouTube audio slider. I use two way data binding like this:
<mat-slider min="0" max="1" step="0.01" [(value)]="settingsService.audioTick.volume"></mat-slider>
The problem is, the value will only get updated when I stop dragging the slider. Which is a bad user experience because I don't immediately hear if that is a good volume. So I somehow need to do data binding while dragging.
Here is a StackBlitz: https://stackblitz.com/angular/rojampjmlap
Any Idea?
angular angular-material
add a comment |
up vote
1
down vote
favorite
I'm trying to control the audio volume with a material slider. Just like the YouTube audio slider. I use two way data binding like this:
<mat-slider min="0" max="1" step="0.01" [(value)]="settingsService.audioTick.volume"></mat-slider>
The problem is, the value will only get updated when I stop dragging the slider. Which is a bad user experience because I don't immediately hear if that is a good volume. So I somehow need to do data binding while dragging.
Here is a StackBlitz: https://stackblitz.com/angular/rojampjmlap
Any Idea?
angular angular-material
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to control the audio volume with a material slider. Just like the YouTube audio slider. I use two way data binding like this:
<mat-slider min="0" max="1" step="0.01" [(value)]="settingsService.audioTick.volume"></mat-slider>
The problem is, the value will only get updated when I stop dragging the slider. Which is a bad user experience because I don't immediately hear if that is a good volume. So I somehow need to do data binding while dragging.
Here is a StackBlitz: https://stackblitz.com/angular/rojampjmlap
Any Idea?
angular angular-material
I'm trying to control the audio volume with a material slider. Just like the YouTube audio slider. I use two way data binding like this:
<mat-slider min="0" max="1" step="0.01" [(value)]="settingsService.audioTick.volume"></mat-slider>
The problem is, the value will only get updated when I stop dragging the slider. Which is a bad user experience because I don't immediately hear if that is a good volume. So I somehow need to do data binding while dragging.
Here is a StackBlitz: https://stackblitz.com/angular/rojampjmlap
Any Idea?
angular angular-material
angular angular-material
asked yesterday
Jonas
336114
336114
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can use the [value]
property binding syntax to pass someValue
as an @Input
to MatSlider
. MatSlider
has an @Output
property defined named input
that gets triggered when the input
value changes. You can listen to that and simply re-assign whatever is returned as the $event
data to someValue
.
Here, give this a try:
Template:
<mat-slider
(input)="someValue = $event.value"
[value]="someValue">
</mat-slider>
{{ someValue }}
Component:
import {Component} from '@angular/core';
@Component({...})
export class SliderOverviewExample {
someValue = 0;
}
Here's an Updated Sample StackBlitz for your ref.
Thanks, works great!
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
You need to bind to the input
Output property to get the live data change. Example:
<mat-slider
min="0"
max="1"
step="0.01"
(input)="settingsService.audioTick.volume = $event.value"
[value]="settingsService.audioTick.volume" />
3
You shouldn't two-way bind[(value)]
and also bind(input)
to the same property. Just read bind[value]
.
– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can use the [value]
property binding syntax to pass someValue
as an @Input
to MatSlider
. MatSlider
has an @Output
property defined named input
that gets triggered when the input
value changes. You can listen to that and simply re-assign whatever is returned as the $event
data to someValue
.
Here, give this a try:
Template:
<mat-slider
(input)="someValue = $event.value"
[value]="someValue">
</mat-slider>
{{ someValue }}
Component:
import {Component} from '@angular/core';
@Component({...})
export class SliderOverviewExample {
someValue = 0;
}
Here's an Updated Sample StackBlitz for your ref.
Thanks, works great!
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
accepted
You can use the [value]
property binding syntax to pass someValue
as an @Input
to MatSlider
. MatSlider
has an @Output
property defined named input
that gets triggered when the input
value changes. You can listen to that and simply re-assign whatever is returned as the $event
data to someValue
.
Here, give this a try:
Template:
<mat-slider
(input)="someValue = $event.value"
[value]="someValue">
</mat-slider>
{{ someValue }}
Component:
import {Component} from '@angular/core';
@Component({...})
export class SliderOverviewExample {
someValue = 0;
}
Here's an Updated Sample StackBlitz for your ref.
Thanks, works great!
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can use the [value]
property binding syntax to pass someValue
as an @Input
to MatSlider
. MatSlider
has an @Output
property defined named input
that gets triggered when the input
value changes. You can listen to that and simply re-assign whatever is returned as the $event
data to someValue
.
Here, give this a try:
Template:
<mat-slider
(input)="someValue = $event.value"
[value]="someValue">
</mat-slider>
{{ someValue }}
Component:
import {Component} from '@angular/core';
@Component({...})
export class SliderOverviewExample {
someValue = 0;
}
Here's an Updated Sample StackBlitz for your ref.
You can use the [value]
property binding syntax to pass someValue
as an @Input
to MatSlider
. MatSlider
has an @Output
property defined named input
that gets triggered when the input
value changes. You can listen to that and simply re-assign whatever is returned as the $event
data to someValue
.
Here, give this a try:
Template:
<mat-slider
(input)="someValue = $event.value"
[value]="someValue">
</mat-slider>
{{ someValue }}
Component:
import {Component} from '@angular/core';
@Component({...})
export class SliderOverviewExample {
someValue = 0;
}
Here's an Updated Sample StackBlitz for your ref.
edited yesterday
answered yesterday
SiddAjmera
10.1k21137
10.1k21137
Thanks, works great!
– Jonas
12 hours ago
add a comment |
Thanks, works great!
– Jonas
12 hours ago
Thanks, works great!
– Jonas
12 hours ago
Thanks, works great!
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
You need to bind to the input
Output property to get the live data change. Example:
<mat-slider
min="0"
max="1"
step="0.01"
(input)="settingsService.audioTick.volume = $event.value"
[value]="settingsService.audioTick.volume" />
3
You shouldn't two-way bind[(value)]
and also bind(input)
to the same property. Just read bind[value]
.
– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
You need to bind to the input
Output property to get the live data change. Example:
<mat-slider
min="0"
max="1"
step="0.01"
(input)="settingsService.audioTick.volume = $event.value"
[value]="settingsService.audioTick.volume" />
3
You shouldn't two-way bind[(value)]
and also bind(input)
to the same property. Just read bind[value]
.
– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
add a comment |
up vote
2
down vote
up vote
2
down vote
You need to bind to the input
Output property to get the live data change. Example:
<mat-slider
min="0"
max="1"
step="0.01"
(input)="settingsService.audioTick.volume = $event.value"
[value]="settingsService.audioTick.volume" />
You need to bind to the input
Output property to get the live data change. Example:
<mat-slider
min="0"
max="1"
step="0.01"
(input)="settingsService.audioTick.volume = $event.value"
[value]="settingsService.audioTick.volume" />
edited yesterday
answered yesterday
Teddy Sterne
6,47811528
6,47811528
3
You shouldn't two-way bind[(value)]
and also bind(input)
to the same property. Just read bind[value]
.
– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
add a comment |
3
You shouldn't two-way bind[(value)]
and also bind(input)
to the same property. Just read bind[value]
.
– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
3
3
You shouldn't two-way bind
[(value)]
and also bind (input)
to the same property. Just read bind [value]
.– G. Tranter
yesterday
You shouldn't two-way bind
[(value)]
and also bind (input)
to the same property. Just read bind [value]
.– G. Tranter
yesterday
Thank you! Works like it should
– Jonas
12 hours ago
Thank you! Works like it should
– Jonas
12 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401623%2fangular-matrial-slider-data-binding-while-dragging%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown