Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1b18902

Browse files
IgorMinarrodyhaddad
authored andcommitted
perf(ngBind): set the ng-binding class during compilation instead of linking
1 parent 6d418ef commit 1b18902

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/ng/directive/ngBind.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@
5050
</file>
5151
</example>
5252
*/
53-
var ngBindDirective = ngDirective(function(scope, element, attr) {
54-
element.addClass('ng-binding').data('$binding', attr.ngBind);
55-
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
56-
// We are purposefully using == here rather than === because we want to
57-
// catch when value is "null or undefined"
58-
// jshint -W041
59-
element.text(value == undefined ? '' : value);
60-
});
53+
var ngBindDirective = ngDirective({
54+
compile: function(templateElement) {
55+
templateElement.addClass('ng-binding');
56+
return function (scope, element, attr) {
57+
element.data('$binding', attr.ngBind);
58+
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
59+
// We are purposefully using == here rather than === because we want to
60+
// catch when value is "null or undefined"
61+
// jshint -W041
62+
element.text(value == undefined ? '' : value);
63+
});
64+
};
65+
}
6166
});
6267

6368

0 commit comments

Comments
 (0)