Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbbr/ngnode
AngularJS Directive Helper service
https://github.com/gbbr/ngnode
Last synced: about 1 month ago
JSON representation
AngularJS Directive Helper service
- Host: GitHub
- URL: https://github.com/gbbr/ngnode
- Owner: gbbr
- Created: 2014-05-31T19:28:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-31T21:53:00.000Z (over 10 years ago)
- Last Synced: 2023-08-14T11:32:30.165Z (over 1 year ago)
- Homepage:
- Size: 168 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ngNode
#### Lightweight directive helper serviceProvides the $node helper service to directives for easy access to DOM Elements in their templates.
To use, add the `ng-node` attribute to the desired HTML Elements and pass the desired $node property name as value.
For example, using `ng-node="btnCancel` will make `$node.btnCancel` available on the service for the directive.Improves mainainability and readibility. Helps leave out redundant DOM queries.
__HTML__
```html
Home
Contact
```
__JS__
```js
angular.module('myModule', ['ngNode']);
angular.module('myModule').directive('myDirective', function($node) {
/* ... */
return {
restrict: 'E',
link: function() {
$node.btnHome.on('click', goHome);
$node.btnContact.on('click', showContact);
$node.txtOutput.html('Hello world!');
}
}
});
```WARNING: Do not use within controllers. DOM Manipulation should only be done in directives according to AngularJS best practices.