©
Ce document utilise Manuel du site Web PHP chinois Libérer
A shared object between directive compile / linking functions which contains normalized DOM
element attributes. The values reflect current binding state {{ }}
. The normalization is
needed since all of these are treated as equivalent in Angular:
<span ng:bind="a" ng-bind="a" data-ng-bind="a" x-ng-bind="a">
$addClass(classVal);
Adds the CSS class value specified by the classVal parameter to the element. If animations are enabled then an animation will be triggered for the class addition.
参数 | 类型 | 详述 |
---|---|---|
classVal | string |
The className value that will be added to the element |
$removeClass(classVal);
Removes the CSS class value specified by the classVal parameter from the element. If animations are enabled then an animation will be triggered for the class removal.
参数 | 类型 | 详述 |
---|---|---|
classVal | string |
The className value that will be removed from the element |
$updateClass(newClasses, oldClasses);
Adds and removes the appropriate CSS class values to the element based on the difference between the new and old CSS class values (specified as newClasses and oldClasses).
参数 | 类型 | 详述 |
---|---|---|
newClasses | string |
The current CSS className value |
oldClasses | string |
The former CSS className value |
$observe(key, fn);
Observes an interpolated attribute.
The observer function will be invoked once during the next $digest
following
compilation. The observer is then invoked whenever the interpolated value
changes.
参数 | 类型 | 详述 |
---|---|---|
key | string |
Normalized key. (ie ngAttribute) . |
fn | function(interpolatedValue) |
Function that will be called whenever the interpolated value of the attribute changes. See the Directives guide for more info. |
function() |
Returns a deregistration function for this observer. |
$set(名称, value);
Set DOM element attribute value.
参数 | 类型 | 详述 |
---|---|---|
name | string |
Normalized element attribute name of the property to modify. The name is reverse-translated using the $attr property to the original name. |
value | string |
Value to set the attribute to. The value can be an interpolated string. |
$attr