Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<h1>angular-checkbox-set</h1> | ||
|
||
<p>Angular directive, with recursive support for multiple layers of checkboxes.</p> | ||
|
||
<ol> | ||
<li>The <code>checked</code> status would be stored in a unique object for each checkbox. This attribute is mandatory.</li> | ||
<li>The <code>hook</code> and <code>hooked-to</code> attributes are optional. <code>hook</code> act as a hook, <code>hooked-to</code> hook the checkbox to the filled-in hook.</li> | ||
<li>A checkbox could have both <code>hook</code> and <code>hooked-to</code> attributes, which means:</li> | ||
<li>You could have as many levels of checkboxes as you like.</li> | ||
<li>No need to initialise all the checkboxes at the same time: you could put children checkboxes inside <code>ng-if</code>s and when they come into existence, they’ll automatically follow the status of their parent.</li> | ||
</ol> | ||
|
||
|
||
<h3>Install</h3> | ||
|
||
<p><code>command | ||
$ bower install angular-checkbox-set | ||
</code></p> | ||
|
||
<h3>Directive Attributes</h3> | ||
|
||
<ol> | ||
<li><code>hook</code>, string. <strong>Notice the single quote within double quote!</strong></li> | ||
<li><code>hooked-to</code>, string. Same as above.</li> | ||
<li><code>status-stored-in</code>, scope object.</li> | ||
</ol> | ||
|
||
|
||
<h3>Code Example</h3> | ||
|
||
<p>```html</p> | ||
|
||
<!-- provide a hook string for its children --> | ||
|
||
|
||
<!-- gpObj will have a property "checked", its value would be boolean --> | ||
|
||
|
||
<p><checkbox hook="'grandParent'" status-stored-in="gpObj"></checkbox></p> | ||
|
||
<!-- since these two are hooked to 'grandParent' --> | ||
|
||
|
||
<!-- 1. checking parentA would auto check these two --> | ||
|
||
|
||
<!-- 2. unchecking parentA would auto uncheck these two --> | ||
|
||
|
||
<!-- 3. unchecking either of these would uncheck their hook 'grandParent' --> | ||
|
||
|
||
<!-- 4. if these two are checked, their hook 'grandParent' would be checked --> | ||
|
||
|
||
<p><checkbox hook="'parentA'" hooked-to="'grandParent'" status-stored-in="pObjA"></checkbox> | ||
<checkbox hook="'parentB'" hooked-to="'grandParent'" status-stored-in="pObjB"></checkbox></p> | ||
|
||
<!-- you could link the hooks recursively, and they don't have to be placed in a inherited structure in html --> | ||
|
||
|
||
<p><checkbox hooked-to="'parentA'" status-stored-in="cObjA1"></checkbox> | ||
<checkbox hooked-to="'parentA'" status-stored-in="cObjA2"></checkbox> | ||
```</p> | ||
|
||
<p>See it in action <a href="http://luxiyalu.com/playground/checkbox/">here</a>.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters