Insert (Value)"Slider value" into an Angular Nativescript Label

Asked

Viewed 24 times

-1

Guys, I’m having a problem in my studies in Nativescript/Angular, I’m trying to insert a value of a Slider inside a Label the slider is in the following:

                    <Slider value="1" minValue="0" maxValue="100"
                        (valueChange)="onSliderValueChange($event)">
                    </Slider>

And the TS file is as follows:

    onSliderValueChange(args) {
        let slider = <Slider>args.object;
        console.log(`valor recebido do Slider ${args.value}`);   
    }

Until then everything was quiet, and in the console shows the value of the slider( ${args.value} ) but I didn’t understand how I manipulate the text element inside the label to insert this value.

How is my label:

<Label id="label1" text="Valor do Slider Aqui" textWrap="true"></Label>

Could someone help me? Because the example shown in the documentation didn’t help me much.

1 answer

0

Do So:

               <Slider [value]="value" minValue="0" maxValue="100"
                    (valueChange)="onSliderValueChange($event)">
                </Slider>

TS:

 value=1

 constructor(){}...


onSliderValueChange(args) {
    let slider = <Slider>args.object;
   this.value=args.value;  
}
  • I think I was not very clear, sorry, I need to know how I manipulate the text element of Label to insert in it the value of Slider.

  • The value of the slider is assigned to the value property of your understood component?

  • I get it, thank you!

  • @Jonatasantos, if possible, choose this answer as the best.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.