|
51 | 51 | </file> |
52 | 52 | </example> |
53 | 53 | */ |
54 | | -var ngBindDirective = ngDirective({ |
55 | | - compile: function ngBindCompile(templateElement) { |
56 | | - templateElement.addClass('ng-binding'); |
57 | | - |
58 | | - return function ngBindLink(scope, element, attr) { |
59 | | - element.data('$binding', attr.ngBind); |
60 | | - element = element[0]; |
61 | | - |
62 | | - scope.$watch(attr.ngBind, function ngBindWatchAction(value) { |
63 | | - // We are purposefully using == here rather than === because we want to |
64 | | - // catch when value is "null or undefined" |
65 | | - // jshint -W041 |
66 | | - element.textContent = (value == undefined ? '' : value); |
67 | | - }); |
68 | | - }; |
69 | | - } |
70 | | -}); |
| 54 | +var ngBindDirective = ['$compile', function($compile) { |
| 55 | + return { |
| 56 | + restrict: 'AC', |
| 57 | + compile: function(templateElement) { |
| 58 | + return function (scope, element, attr) { |
| 59 | + $compile.$$addBindingInfo(element, attr.ngBind); |
| 60 | + scope.$watch(attr.ngBind, function ngBindWatchAction(value) { |
| 61 | + // We are purposefully using == here rather than === because we want to |
| 62 | + // catch when value is "null or undefined" |
| 63 | + // jshint -W041 |
| 64 | + element.text(value == undefined ? '' : value); |
| 65 | + }); |
| 66 | + }; |
| 67 | + } |
| 68 | + }; |
| 69 | +}]; |
71 | 70 |
|
72 | 71 |
|
73 | 72 | /** |
@@ -121,11 +120,10 @@ var ngBindDirective = ngDirective({ |
121 | 120 | </file> |
122 | 121 | </example> |
123 | 122 | */ |
124 | | -var ngBindTemplateDirective = ['$interpolate', function($interpolate) { |
| 123 | +var ngBindTemplateDirective = ['$interpolate', '$compile', function($interpolate, $compile) { |
125 | 124 | return function(scope, element, attr) { |
126 | | - // TODO: move this to scenario runner |
127 | 125 | var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate)); |
128 | | - element.addClass('ng-binding').data('$binding', interpolateFn); |
| 126 | + $compile.$$addBindingInfo(element, interpolateFn); |
129 | 127 | attr.$observe('ngBindTemplate', function(value) { |
130 | 128 | element.text(value); |
131 | 129 | }); |
@@ -178,14 +176,13 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) { |
178 | 176 | </file> |
179 | 177 | </example> |
180 | 178 | */ |
181 | | -var ngBindHtmlDirective = ['$sce', '$parse', function($sce, $parse) { |
| 179 | +var ngBindHtmlDirective = ['$sce', '$parse', '$compile', function($sce, $parse, $compile) { |
182 | 180 | return { |
183 | 181 | restrict: 'A', |
184 | | - compile: function ngBindCompile(tElement, tAttrs) { |
185 | | - tElement.addClass('ng-binding'); |
| 182 | + compile: function (tElement, tAttrs) { |
186 | 183 |
|
187 | | - return function ngBindLink(scope, element, attr) { |
188 | | - element.data('$binding', attr.ngBindHtml); |
| 184 | + return function (scope, element, attr) { |
| 185 | + $compile.$$addBindingInfo(element, attr.ngBindHtml); |
189 | 186 | var ngBindHtmlGetter = $parse(attr.ngBindHtml); |
190 | 187 | var ngBindHtmlWatch = $parse(attr.ngBindHtml, function getStringValue(value) { |
191 | 188 | return (value || '').toString(); |
|
0 commit comments