Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 61df40f

Browse files
committed
docs(cb-a11y): Content - Form controls
1 parent 7a62934 commit 61df40f

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

public/docs/_examples/cb-a11y/ts/app/form-controls/a11y-form-controls.component.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ <h3>Explicit labeling</h3>
3939
<hr>
4040
</header>
4141

42-
<a11y-input-explicit [uniqueId]="'forinput'">
43-
Label for input:
44-
</a11y-input-explicit>
42+
<!-- #docregion cb-a11y-form-controls-input-explicit-usage -->
43+
<a11y-input-explicit> Label for input:</a11y-input-explicit>
44+
<!--#enddocregion-->
4545

4646
</section>
4747
<section class="row well">
@@ -61,7 +61,7 @@ <h3>Labeling custom controls</h3>
6161
<hr>
6262
</header>
6363
</section>
64-
<a href="" [routerLink]="['Index']">Back to index...</a>
64+
<a href="" [routerLink]="['Index']">Back to index...</a>
6565
</article>
6666

6767

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
<!-- #docregion-->
12
<div class="form-group">
2-
<!-- #docregion cb-a11y-form-controls-input-explicit -->
33
<label [attr.for]="uniqueId">
44
<ng-content></ng-content>
55
</label>
66
<input [id]="uniqueId"
77
class="form-control">
8-
<!--#enddocregion-->
9-
</div>
8+
</div>
9+
<!--#enddocregion-->

public/docs/ts/latest/cookbook/a11y.jade

+24-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ code-example(language="html" escape="html" format="linenums").
316316
already furnished with id's.
317317

318318
As alternative you can also use the `explicit labelling` syntax. For this syntax you are required to add an `id` to
319-
the `HTML` form element to connect the label up.
319+
the `HTML` form element to connect the label up via a `for / id` pairing [The `for` attribute of the label has to
320+
contain the `id` of the input being labelled].
320321

321322
This is also the reason why `implicit labelling` could come in very useful with reusable Angular&nbsp;2 components.
322323
Remember that an `id` should be unique on a page, and any component where `explicit labelling` is used, will need
@@ -328,6 +329,28 @@ code-example(language="html" escape="html" format="linenums").
328329
**NOTE:** In the example code we are generating `GUID's` for id's to ensure that they are unique. You can use your
329330
own method to do this, as long as every page id is unique.
330331

332+
Your component template:
333+
334+
+makeExample('cb-a11y/ts/app/form-controls/a11y-input-explicit.component.html')
335+
336+
:marked
337+
Used as:
338+
339+
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-input-explicit-usage')
340+
341+
:marked
342+
Which is then rendered as:
343+
344+
code-example(language="html" escape="html" format="linenums").
345+
<a11y-input-explicit>
346+
<div class="form-group">
347+
<label for="c90c7f99-330e-4723-bfa8-9ab72a4bd435">
348+
Label for input:
349+
</label>
350+
<input class="form-control"
351+
id="c90c7f99-330e-4723-bfa8-9ab72a4bd435">
352+
</div>
353+
</a11y-input-explicit>
331354

332355

333356
.l-main-section

0 commit comments

Comments
 (0)