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?










share|improve this question


























    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?










    share|improve this question
























      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?










      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 yesterday









      Jonas

      336114




      336114
























          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            12 hours ago




















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





          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
            yesterday










          • Thank you! Works like it should
            – Jonas
            12 hours ago











          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',
          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








          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            12 hours ago

















          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.






          share|improve this answer























          • Thanks, works great!
            – Jonas
            12 hours ago















          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.






          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 yesterday

























          answered yesterday









          SiddAjmera

          10.1k21137




          10.1k21137












          • Thanks, works great!
            – Jonas
            12 hours ago




















          • Thanks, works great!
            – Jonas
            12 hours ago


















          Thanks, works great!
          – Jonas
          12 hours ago






          Thanks, works great!
          – Jonas
          12 hours ago














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





          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
            yesterday










          • Thank you! Works like it should
            – Jonas
            12 hours ago















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





          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
            yesterday










          • Thank you! Works like it should
            – Jonas
            12 hours ago













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





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














          • 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


















           

          draft saved


          draft discarded



















































           


          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

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...