mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-03 04:34:44 +00:00
refactor(directive): use attrs.$observe
This commit is contained in:
parent
6d0ca95fa0
commit
656a495e50
1 changed files with 6 additions and 6 deletions
|
|
@ -253,10 +253,10 @@ var ngBindHtmlDirective = ['$sanitize', function($sanitize) {
|
||||||
*/
|
*/
|
||||||
var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
|
var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
|
||||||
return function(scope, element, attr) {
|
return function(scope, element, attr) {
|
||||||
var interpolateFn = $interpolate(attr.ngBindTemplate);
|
// TODO: move this to scenario runner
|
||||||
var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate));
|
var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate));
|
||||||
element.addClass('ng-binding').data('$binding', interpolateFn);
|
element.addClass('ng-binding').data('$binding', interpolateFn);
|
||||||
scope.$watch(interpolateFn, function(value) {
|
attr.$observe('ngBindTemplate', function(value) {
|
||||||
element.text(value);
|
element.text(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -901,13 +901,13 @@ var ngCloakDirective = valueFn({
|
||||||
});
|
});
|
||||||
|
|
||||||
function ngAttributeAliasDirective(propName, attrName) {
|
function ngAttributeAliasDirective(propName, attrName) {
|
||||||
ngAttributeAliasDirectives[directiveNormalize('ng-' + attrName)] = ['$interpolate', function($interpolate) {
|
ngAttributeAliasDirectives[directiveNormalize('ng-' + attrName)] = valueFn(
|
||||||
return function(scope, element, attr) {
|
function(scope, element, attr) {
|
||||||
scope.$watch($interpolate(attr[directiveNormalize('ng-' + attrName)]), function(value) {
|
attr.$observe(directiveNormalize('ng-' + attrName), function(value) {
|
||||||
attr.$set(attrName, value);
|
attr.$set(attrName, value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}];
|
);
|
||||||
}
|
}
|
||||||
var ngAttributeAliasDirectives = {};
|
var ngAttributeAliasDirectives = {};
|
||||||
forEach(BOOLEAN_ATTR, ngAttributeAliasDirective);
|
forEach(BOOLEAN_ATTR, ngAttributeAliasDirective);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue