Guest User

Untitled

a guest
Oct 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import { bindable, observable } from 'aurelia-framework';
  2.  
  3. export class CurrencyControl {
  4.  
  5. @bindable
  6. valueX: number;
  7.  
  8. @observable
  9. stringValue: string;
  10.  
  11. valueChanging: boolean = false;
  12.  
  13. constructor() {
  14. }
  15.  
  16. valueXChanged(newValue: number, oldValue: number) {
  17. alert('valueX changed');
  18. if (!this.valueChanging) {
  19. this.valueChanging = true;
  20. this.stringValue = newValue.toString();
  21. this.valueChanging = false;
  22. }
  23. }
  24.  
  25. stringValueChanged(newValue: string, oldValue: string) {
  26. alert('stringValueChanged changed');
  27. this.stringValue = parseFloat(newValue).toFixed(2);
  28. if (!this.valueChanging) {
  29. this.valueChanging = true;
  30. this.valueX = parseFloat(this.stringValue);
  31. this.valueChanging = false;
  32. }
  33. }
  34. }
  35.  
  36. <template>
  37.  
  38. <require from="./currency-control.css"></require>
  39.  
  40. <div class="input-group">
  41. <div class="input-group-addon">&euro;</div>
  42. <input type="text" maxlength="5" pattern="d*" class="form-control" value.bind="stringValue" />
  43. </div>
  44.  
  45. </template>
Add Comment
Please, Sign In to add comment