Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 5d544c0

Browse files
committed
docs(ng-class): expound on the map syntax
Closes #221
1 parent bde52ab commit 5d544c0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/directive/ng_class.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,28 @@ part of angular.directive;
1919
*
2020
* index.html:
2121
*
22-
* <p ng-class="{strike: strike, bold: bold, red: red}">Map Syntax Example</p>
22+
* <!--
23+
* The map syntax:
24+
*
25+
* ng-class="{key1: value1, key2: value2, ...}"
26+
*
27+
* results in only adding CSS classes represented by the map keys when
28+
* the corresponding value expressions are truthy.
29+
*
30+
* To use a css class that contains a hyphen (such as line-through in this
31+
* example), you should quote the name to make it a valid map key. You
32+
* may, of course, quote all the map keys for consistency.
33+
* -->
34+
* <p ng-class="{'line-through': strike, bold: bold, red: red}">Map Syntax Example</p>
2335
* <input type="checkbox" ng-model="bold"> bold
2436
* <input type="checkbox" ng-model="strike"> strike
2537
* <input type="checkbox" ng-model="red"> red
2638
* <hr>
39+
*
2740
* <p ng-class="style">Using String Syntax</p>
2841
* <input type="text" ng-model="style" placeholder="Type: bold strike red">
2942
* <hr>
43+
*
3044
* <p ng-class="[style1, style2, style3]">Using Array Syntax</p>
3145
* <input ng-model="style1" placeholder="Type: bold"><br>
3246
* <input ng-model="style2" placeholder="Type: strike"><br>
@@ -37,6 +51,9 @@ part of angular.directive;
3751
* .strike {
3852
* text-decoration: line-through;
3953
* }
54+
* .line-through {
55+
* text-decoration: line-through;
56+
* }
4057
* .bold {
4158
* font-weight: bold;
4259
* }

0 commit comments

Comments
 (0)