How to effectively use $watch, $digest, and $apply in AngularJS?