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
- Host: GitHub
- URL: https://github.com/chrisyip/ng-attrs
- Owner: chrisyip
- License: mit
- Created: 2015-04-12T18:44:42.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-13T06:16:14.000Z (about 11 years ago)
- Last Synced: 2025-11-11T06:16:09.572Z (7 months ago)
- Language: HTML
- Homepage: http://chrisyip.github.io/ng-attrs
- Size: 150 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)