Mainly Devel Notes

Twitter, GitHub, StackOverflow: @ovrmrw (short hand of "overmorrow" that means the day after tomorrow)

ko.computed(Knockout) equivalent in Angular + TypeScript

sometimes it is calculated by Angular, sometimes you fill it by hand.

My most familiar JavaScript library is KnockoutJS.
Especially I like ko.computed that is a mighty feature of Knockout. When observed variables are changed, Knockout triggers Dependency Tracking chain. Then all variables needed to update will be updated automatically.
This sample is for a typical case of business apps with ko.computed equivalent in Angular. (+ TypeScript)

また、TypeScriptを使うことでJavaScriptにありがちな追跡困難なエラーとの不本意な長期戦を避けられます。Angular 2での採用も決まっていますのでまだの人は是非。


(index.html and myScript.ts on Gist)

Angular Sample - Calculating Amount with Quantity and Price

Remove all ads