aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/api
diff options
context:
space:
mode:
authorVojta Jina2012-03-07 14:04:14 -0800
committerVojta Jina2012-03-07 14:04:14 -0800
commit6aa3cfc31b14bfe74d89030fb6c2d615e44f2845 (patch)
tree3d37ffca202e0d8133144b0ae1c824cfd5fd184e /docs/content/api
parent64912069caeb5a05da449b6ee04c965477f3ae25 (diff)
downloadangular.js-6aa3cfc31b14bfe74d89030fb6c2d615e44f2845.tar.bz2
docs($compileProvider.directive): Update iAttrs docs
Diffstat (limited to 'docs/content/api')
-rw-r--r--docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc22
1 files changed, 21 insertions, 1 deletions
diff --git a/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc b/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc
index 56dbcbd8..40f272c0 100644
--- a/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc
+++ b/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc
@@ -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