You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Follow the [setup](setup.html) instructions for creating a new project
60
+
Follow the [setup](setup.html) instructions for creating a new local project
71
61
named <span ngio-ex>attribute-directives</span>.
72
62
73
63
:marked
74
-
Create the following source file in the indicated folder with the following code:
64
+
Create the following source file in `src/app` with the following code:
75
65
+makeExample('src/app/highlight.directive.1.ts')
76
66
77
67
blockhighlight-directive-1
@@ -91,14 +81,14 @@ block highlight-directive-1
91
81
The [CSS selector for an attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors)
92
82
is the attribute name in square brackets.
93
83
Here, the directive's selector is `[myHighlight]`.
94
-
Angular will locate all elements in the template that have an attribute named `myHighlight`.
84
+
Angular locates all elements in the template that have an attribute named `myHighlight`.
95
85
.l-sub-section
96
86
:marked
97
87
### Why not call it "highlight"?
98
88
Though *highlight* is a more concise name than *myHighlight* and would work,
99
89
a best practice is to prefix selector names to ensure
100
90
they don't conflict with standard HTML attributes.
101
-
This also reduces the risk colliding with third-party directive names.
91
+
This also reduces the risk of colliding with third-party directive names.
102
92
103
93
Make sure you do **not** prefix the `highlight` directive name with **`ng`** because
104
94
that prefix is reserved for Angular and using it could cause bugs that are difficult to diagnose. For a simple demo, the short prefix, `my`, helps distinguish your custom directive.
@@ -120,7 +110,7 @@ a#apply-directive
120
110
## Apply the attribute directive
121
111
To use the new `HighlightDirective`, create a template that
122
112
applies the directive as an attribute to a paragraph (`<p>`) element.
123
-
In Angular terms, the `<p>` element will be the attribute **host**.
113
+
In Angular terms, the `<p>` element is the attribute **host**.
124
114
p
125
115
| Put the template in its own
126
116
code #[+adjExPath('app.component.html')]
@@ -210,7 +200,7 @@ a#bindings
210
200
## Pass values into the directive with an _@Input_ data binding
211
201
212
202
Currently the highlight color is hard-coded _within_ the directive. That's inflexible.
213
-
Let the user of the directive set the color in the template with a binding.
203
+
In this section, you give the developer the power to set the highlight color while applying the directive.
214
204
215
205
Start by adding a `highlightColor` property to the directive class like this:
0 commit comments