Question

I have a subscribe function which fires when the dropdown value changes. I want to update another observable value inside this subscribe function. The probelm is when the control leaves this subscribe function the observable value got null or empty.

self.selectedSubAccount.subscribe(function (newValue) {
 //alert("The Selected Account Code:" + newValue);
 var likeCode = newValue.substring(0, 2);
 var accType = "Control";
 self.ACCOUNT_CODE = GenrateAccountCode(self.SUBACCOUNTS(), likeCode, accType);
});
Was it helpful?

Solution

Assuming self.ACCOUNT_CODE is your observable, you would update it like so:

self.ACCOUNT_CODE(GenrateAccountCode(self.SUBACCOUNTS(), likeCode, accType));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top