You need to use $observe to watch DOM attributes who's values contain
interpolation.

<span title="Hello {{name}}">blah</span>

attrs.$observe('title', function() {
   ...
});

$watch can not be used for string expressions that contain interpolation.

http://ng.malsup.com/#!/$watch-vs-$observe




On Fri, Jan 31, 2014 at 9:16 AM, LLoydsensei <[email protected]> wrote:

> Hi guys.
>
> API documentation (
> http://docs.angularjs.org/api/ng.$compile#description_comprehensive-directive-api_attributes)
> says  "[...] during the linking phase the interpolation hasn't been
> evaluated yet and so the value is at this time set to undefined."
>
> 1) I cannot understand why someone would use attrs.$observe() instead of
> $scope.$watch(), since both appear to work the same way
> 2) I don't understand why the documentation talks about the interpolation
> being undefined during the linking phase when this
> http://jsfiddle.net/3Vh43/1/ proves the contrary
>
> Did I happen to stumble upon a particular case in my jsfiddle where it
> works or is the documentation wrong there?
>
> Regards,
> LLoyd
>
> PS: Wiki says the same (
> https://github.com/angular/angular.js/wiki/Understanding-Scopes#-directives
> )
> PPS: Tested on angular 1.1.5 and 1.2.10
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to