Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit d4730a9

Browse files
clshortfuseThomasBurleson
authored andcommitted
docs(icon): use ng-bind for md-icon ligature documentation (#9777)
For md-icon font ligatures, `ng-bind` should be used, to keep logic modular inside the md-icon declaration. This is also an important change for users that use multilingual support in their applications and use our demo code as a template * Update icon demo to use ng-bind instead of inline text interpolization * Update icon documentation to explain ng-bind usage and its importance with localization support `ng-bind` is more also more efficient than text interpolization. Fixes #9750
1 parent 3ab002f commit d4730a9

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/components/icon/demoFontIconsWithLigatures/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<md-icon ng-style="{color: font.color}"
1313
aria-label="{{ font.name }}"
1414
class="material-icons step"
15-
ng-class="it.size">
16-
{{ font.name }}
15+
ng-class="it.size"
16+
ng-bind="font.name">
1717
</md-icon>
1818
</div>
1919
</div>

src/components/icon/js/iconDirective.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ angular
4848
* rel="stylesheet">`
4949
* </li>
5050
* <li>
51-
* Use either (a) font-icon class names or (b) font ligatures to render the font glyph by using
52-
* its textual name
51+
* Use either (a) font-icon class names or (b) a fontset and a font ligature to render the font glyph by
52+
* using its textual name _or_ numerical character reference. Note that `material-icons` is the default fontset when
53+
* none is specified.
5354
* </li>
54-
* <li>
55-
* Use `<md-icon md-font-icon="classname" />` or <br/>
56-
* use `<md-icon md-font-set="font library classname or alias"> textual_name </md-icon>` or <br/>
57-
* use `<md-icon md-font-set="font library classname or alias"> numerical_character_reference </md-icon>`
55+
* <li> Use any of the following templates: <br/>
56+
* <ul>
57+
* <li>`<md-icon md-font-icon="classname"></md-icon>`</li>
58+
* <li>`<md-icon md-font-set="font library classname or alias">textual_name</md-icon>`</li>
59+
* <li>`<md-icon> numerical_character_reference </md-icon>`</li>
60+
* <li>`<md-icon ng_bind="'textual_name'"></md-icon>`</li>
61+
* <li>`<md-icon ng-bind="scopeVariable"></md-icon>`</li>
62+
* </ul>
5863
* </li>
5964
* </ol>
6065
*
@@ -73,6 +78,19 @@ angular
7378
* <li>https://design.google.com/icons/#ic_accessibility</li>
7479
* </ul>
7580
*
81+
* ### Localization
82+
*
83+
* Because an `md-icon` element's text content is not intended to translated, it is recommended to declare the text
84+
* content for an `md-icon` element in its start tag. Instead of using the HTML text content, consider using `ng-bind`
85+
* with a scope variable or literal string.
86+
*
87+
* Examples:
88+
*
89+
* <ul>
90+
* <li>`<md-icon ng-bind="myIconVariable"></md-icon>`</li>
91+
* <li>`<md-icon ng-bind="'menu'"></md-icon>`
92+
* </ul>
93+
*
7694
* <h2 id="material_design_icons">Material Design Icons</h2>
7795
* Using the Material Design Icon-Selector, developers can easily and quickly search for a Material Design font-icon and
7896
* determine its textual name and character reference code. Click on any icon to see the slide-up information

0 commit comments

Comments
 (0)