Comment

Comment by mortalapeman

The only reason one would use scope.$watch in this fashion is to have a function executed when a digest occurs. The original purpose of the $watch function is to take 2 functions, one that returns the watched value and another to be executed when that value changes. The fiddle provided is not a very good example of "reusable" directives. The fiddle could be rewritten to use a directive that adds or removes a given class based on a boolean, and the rest of the state could be handled by built in directives.
parent mortalapeman 13 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton