mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 03:30:02 +08:00
perf(ngBind): set the ng-binding class during compilation instead of linking
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user