简体   繁体   English

Angular 2 Md滑块更改事件,值保持不变

[英]Angular 2 Md Slider change event, value remains the same

I have a typescript angular 4 frontend project where i want to change the initial value of a md slider element and on change event make a web api call with that changed value. 我有一个打字稿角4前端项目,我想在其中更改md滑块元素的初始值,并在更改事件上使用更改后的值进行网络api调用。 The change event is called when i move the slider in the page but on the change event in my component the value remains what it was initially. 当我在页面中移动滑块时,将调用change事件,但是在组件中的change事件上,该值将保持最初的值。 How do I get the changed value in my component so that I can make a web api call ? 如何在组件中获取更改后的值,以便可以进行Web api调用?

You should pass $event.value from view to component. 您应该将$event.value从视图传递到组件。 The $event.value emits the new value. $event.value发出新值。

Example: 例:

<md-slider (change)="someFucn($event.value)"></md-slider>

ts: ts:

someFucn(newVal){
  alert("Slider val: " + newVal);
  // Add API code here
}

Plunker demo 柱塞演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当 slider 值与初始值相同时,如何触发 html 输入类型 = 范围的更改事件 - How to fire a change event for html input type=range when slider value is same as initial value 事件更改时Jquery滑块更新值 - Jquery slider update value on event change Angular Material 2-在单元测试的md复选框中触发更改事件 - Angular Material 2 - Trigger change event in md-checkbox in a Unit Test 防止角材料md-tab中的制表符更改事件 - Prevent tab change event in angular material md-tab Angular:更改输入事件的值 - Angular: change value on input event 如何在Material Angular中向下滚动时更改md-whiteframe值 - How to change md-whiteframe value on scroll down in Material Angular 如何在更改事件或立即值更改事件中获取纸张滑块的立即值/当前值 - How to get immediate value /current value of paper-slider on change event or immediate value change event 在页脚中显示总计,以便一旦更改为true,则在页面更改时值保持不变 - Display grand total in the footer so that value remains same on page change for load once true Angular Material md-slider:Vertical Slider在md-sidenav中不起作用 - Angular Material md-slider: Vertical Slider will not work in md-sidenav 剔除对象值更改,但ui保持不变 - knockout object value changes but ui remains the same
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM