Created
November 22, 2019 09:59
-
-
Save whisher/5bc53200f95c6a270c11eae0ce559d65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let starterChanges$ = of(null); | |
const starter = this.frm.get('starter'); | |
if (starter) { | |
starterChanges$ = starter.valueChanges; | |
} | |
let spreadChanges$ = of(null); | |
const spread = this.frm.get('spread'); | |
if (spread) { | |
spreadChanges$ = spread.valueChanges; | |
} | |
this.subscription.add( | |
combineLatest([starterChanges$, spreadChanges$]).subscribe( | |
([st = 0, sp = 0]) => { | |
let current = 0; | |
if (typeof st === 'number' && typeof sp === 'number') { | |
for (const control of this.orders.controls) { | |
if (!current) { | |
current = current + st + sp; | |
} else { | |
current = current + sp; | |
} | |
control.patchValue({ spread: current }); | |
control.disable(); | |
} | |
} | |
} | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment