An open API service indexing awesome lists of open source software.

https://github.com/chrisyip/ng-attrs

Dynamic set or remove attributes in Angular
https://github.com/chrisyip/ng-attrs

Last synced: 5 months ago
JSON representation

Dynamic set or remove attributes in Angular

Awesome Lists containing this project

README

          

# ng-attrs

Dynamic set or remove attributes in Angular, like `ngClass` for classes.

# Install

Bower:

```
bower install ng-attrs
```

Or manually download it.

# Usage

```html

angular.module('yourApp', ['ngAttrs'])



```

The different between [`ngAttr`](https://docs.angularjs.org/guide/directive#-ngattr-attribute-bindings) and `ngAttrs` is when value is:

- `true`: `ngAttrs` will set attribute to `''`, useful for attribute that doesn't have value, e.g. `contenteditable`, `novalidate`; `ngAttr` will just set attribute to `'true'`, e.g. `contenteditable="true"`.
- `false` or `undefined`: `ngAttrs` will remove attribute from element, `ngAttr` will keep attribute without value.
- Other data types, `ngAttrs` and `ngAttr` will convert it to `String` and set it as value.

# Todo

- Support package managers
- Source map
- Tests

# Author

[Chris Yip](https://github.com/chrisyip)