angular/angular.js — pull request #3408 by slundberg (2013-07-31 19:59:56+00:00)
Title: Issues #1941 - This fixes an issue that sometimes breaks $observe sing a templateUrl for a directive. 

http://plnkr.co/edit/xJNt918gEpuXR026VuZB?p=preview illustrates the issue that this pull request addresses.

When a node is cloned because the beforeTemplateLinkNode !== beforeTemplateCompileNode condition was met, then this would cause the link functions to create a new attrs object, but by setting their last argument to "true" below we force them to keep the same attrs object. Without this flag the $$observers is put on the afterTemplateNodeLinkFn version of attrs and the $set is called on the beforeTemplateNodeLinkFn version of the attrs whenever we make a cloned linkNode above, thus breaking $observe. See github issue #1941

I have not contributed to angular before so I imagine some testing and review is needed but I wanted to offer this patch (which resolved the problem) as a starting point.

Thanks.