perf(ngBind): set the ng-binding class during compilation instead of linking

This commit is contained in:
Igor Minar
2014-06-05 06:36:20 -07:00
committed by rodyhaddad
parent 6d418ef5e3
commit 1b1890274e

View File

@@ -50,14 +50,19 @@
</file>
</example>
*/
var ngBindDirective = ngDirective(function(scope, element, attr) {
element.addClass('ng-binding').data('$binding', attr.ngBind);
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
// We are purposefully using == here rather than === because we want to
// catch when value is "null or undefined"
// jshint -W041
element.text(value == undefined ? '' : value);
});
var ngBindDirective = ngDirective({
compile: function(templateElement) {
templateElement.addClass('ng-binding');
return function (scope, element, attr) {
element.data('$binding', attr.ngBind);
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
// We are purposefully using == here rather than === because we want to
// catch when value is "null or undefined"
// jshint -W041
element.text(value == undefined ? '' : value);
});
};
}
});