Created
November 26, 2020 12:01
-
-
Save rezanid/5040d21c2d300781d3b80a2ea3e85c0a to your computer and use it in GitHub Desktop.
How to define a computed property in ViewModel, KnockoutJS, TypeScript
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
module SampleModule { | |
export class SampleComponent { | |
isValid: KnockoutComputed<boolean>; | |
//... | |
constructor(public element) { | |
//... | |
this.isValidConnectAs = ko.computed<boolean>({ | |
owner: this, | |
read: () => { | |
return this.connectAs().duser().length === 7; | |
} | |
}); | |
ko.applyBindings(this, element); | |
} | |
//... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment