docs($compileProvider.directive): Update iAttrs docs

This commit is contained in:
Vojta Jina 2012-03-07 14:04:14 -08:00
parent 64912069ca
commit 6aa3cfc31b

View file

@ -500,7 +500,7 @@ Executed after the child elements are linked. Safe to do DOM transformation in h
The attributes object - passed as a parameter in the link() or compile() functions - is a way of
accessing:
* *normalize attribute names:* Since a directive such as 'ngBind' can be expressed in many ways
* *normalized attribute names:* Since a directive such as 'ngBind' can be expressed in many ways
sucha s as 'ng:bind', or 'x-ng-bind', the attributes object allows for a normalize accessed to
the attributes.
@ -511,6 +511,26 @@ accessing:
* *supports interpolation:* Interpolation attributes are assigned to the attribute object
allowing other directives to read the interpolated value.
* *observing interpolated attributes:* Use `$observe` to observe the value changes of attributes
that contain interpolation (e.g. `src="{{bar}}"`). Not only is this very efficient but it's also
the only way to easily get the actual value because during the linking phase the interpolation
hasn't been evaluated yet and so the value is at this time set to `undefined`.
<pre>
function linkingFn(scope, elm, attrs, ctrl) {
// get the attribute value
console.log(attrs.ngModel);
// change the attribute
attrs.$set('ngModel', 'new value');
// observe changes to interpolated attribute
attrs.$observe('ngModel', function(value) {
console.log('ngModel has changed value to ' + value);
});
}
</pre>
# Understanding Transclusion and Scopes