# Class Attributes

- Defined in core/compile/attributes.js:26

#####
Index

### Constructors

constructor

### Properties

$$element
$$observers
$animate
$attr
$exceptionHandler
$normalize
$rootScope
$sce
srcset

### Methods

$addClass
$observe
$removeClass
$set
$updateClass
sanitizeSrcset
setSpecialAttr

##
Constructors

### constructor

- new Attributes($rootScope, $animate, $exceptionHandler, $sce, element?, attributesToCopy?): Attributes

- #### Parameters

  - $rootScope: Scope
  - $animate: any
  - $exceptionHandler: any
  - $sce: any
  - `Optional` element: JQLite
  - `Optional` attributesToCopy: any

  #### Returns Attributes

  - Defined in core/compile/attributes.js:35

##
Properties

### $$element

$$element: JQLite

- Defined in core/compile/attributes.js:56

### $$observers

$$observers: any

- Defined in core/compile/attributes.js:209

### $animate

$animate: any

- Defined in core/compile/attributes.js:44

### $attr

$attr: {}

- Defined in core/compile/attributes.js:54

### $exceptionHandler

$exceptionHandler: any

- Defined in core/compile/attributes.js:45

### $normalize

$normalize: ((name: string) => string) = directiveNormalize

Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or `data-`) to its normalized, camelCase form.

Also there is special case for Moz prefix starting with upper case letter.

For further information check out the guide on guide/directive#matching-directives Matching Directives

#### Type declaration

- - (name): string

  - Converts all accepted directives format into proper directive name.

    #### Parameters

    - name: string

      Name to normalize

    #### Returns string

#### Param: name

Name to normalize

- Defined in core/compile/attributes.js:69

### $rootScope

$rootScope: Scope

- Defined in core/compile/attributes.js:43

### $sce

$sce: any

- Defined in core/compile/attributes.js:46

### srcset

srcset: any

- Defined in core/compile/attributes.js:157

##
Methods

### $addClass

- $addClass(classVal): void

- 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.

  #### Parameters

  - classVal: string

    The className value that will be added to the element

  #### Returns void

  - Defined in core/compile/attributes.js:77

### $observe

- $observe(key, fn): (() => any)

- 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.

  #### Parameters

  - key: string

    Normalized key. (ie ngAttribute) .

  - fn: any

    Function that will be called whenever the interpolated value of the attribute changes. See the guide/interpolation#how-text-and-attribute-bindings-work Interpolation guide for more info.

  #### Returns (() => any)

  Returns a deregistration function for this observer.

  - - (): any

    - #### Returns any

  - Defined in core/compile/attributes.js:207

### $removeClass

- $removeClass(classVal): void

- 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.

  #### Parameters

  - classVal: string

    The className value that will be removed from the element

  #### Returns void

  - Defined in core/compile/attributes.js:89

### $set

- $set(key, value, writeAttr, attrName): void

- Set a normalized attribute on the element in a way such that all directives can share the attribute. This function properly handles boolean attributes.

  #### Parameters

  - key: string

    Normalized key. (ie ngAttribute)

  - value: string | boolean

    The value to set. If `null` attribute will be deleted.

  - writeAttr: boolean

    If false, does not write the value to DOM element attribute. Defaults to true.

  - attrName: string

    Optional none normalized name. Defaults to key.

  #### Returns void

  - Defined in core/compile/attributes.js:123

### $updateClass

- $updateClass(newClasses, oldClasses): void

- 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).

  #### Parameters

  - newClasses: string

    The current CSS className value

  - oldClasses: string

    The former CSS className value

  #### Returns void

  - Defined in core/compile/attributes.js:102

### sanitizeSrcset

- sanitizeSrcset(value, invokeType): any

- #### Parameters

  - value: any
  - invokeType: any

  #### Returns any

  - Defined in core/compile/attributes.js:244

### setSpecialAttr

- setSpecialAttr(element, attrName, value): void

- #### Parameters

  - element: any
  - attrName: any
  - value: any

  #### Returns void

  - Defined in core/compile/attributes.js:229