Angular Matrial Slider Data Binding while dragging












1














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?










share|improve this question



























    1














    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?










    share|improve this question

























      1












      1








      1







      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 21:13









      Jonas

      366116




      366116
























          2 Answers
          2






          active

          oldest

          votes


















          2














          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            Nov 21 at 15:19





















          2














          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" />





          share|improve this answer



















          • 3




            You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
            – G. Tranter
            Nov 20 at 21:23










          • Thank you! Works like it should
            – Jonas
            Nov 21 at 15:20











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            Nov 21 at 15:19


















          2














          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            Nov 21 at 15:19
















          2












          2








          2






          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.






          share|improve this answer














          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 at 21:32

























          answered Nov 20 at 21:26









          SiddAjmera

          12.4k31137




          12.4k31137












          • Thanks, works great!
            – Jonas
            Nov 21 at 15:19




















          • Thanks, works great!
            – Jonas
            Nov 21 at 15:19


















          Thanks, works great!
          – Jonas
          Nov 21 at 15:19






          Thanks, works great!
          – Jonas
          Nov 21 at 15:19















          2














          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" />





          share|improve this answer



















          • 3




            You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
            – G. Tranter
            Nov 20 at 21:23










          • Thank you! Works like it should
            – Jonas
            Nov 21 at 15:20
















          2














          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" />





          share|improve this answer



















          • 3




            You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
            – G. Tranter
            Nov 20 at 21:23










          • Thank you! Works like it should
            – Jonas
            Nov 21 at 15:20














          2












          2








          2






          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" />





          share|improve this answer














          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" />






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 at 21:29

























          answered Nov 20 at 21:20









          Teddy Sterne

          6,74311529




          6,74311529








          • 3




            You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
            – G. Tranter
            Nov 20 at 21:23










          • Thank you! Works like it should
            – Jonas
            Nov 21 at 15:20














          • 3




            You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
            – G. Tranter
            Nov 20 at 21:23










          • Thank you! Works like it should
            – Jonas
            Nov 21 at 15:20








          3




          3




          You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
          – G. Tranter
          Nov 20 at 21:23




          You shouldn't two-way bind [(value)] and also bind (input) to the same property. Just read bind [value].
          – G. Tranter
          Nov 20 at 21:23












          Thank you! Works like it should
          – Jonas
          Nov 21 at 15:20




          Thank you! Works like it should
          – Jonas
          Nov 21 at 15:20


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Wiesbaden

          To store a contact into the json file from server.js file using a class in NodeJS

          Marschland