문제

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);
});
도움이 되었습니까?

해결책

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

self.ACCOUNT_CODE(GenrateAccountCode(self.SUBACCOUNTS(), likeCode, accType));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top