MCPcopy Create free account
hub / github.com/angular/angular / Directive

Interface Directive

packages/core/src/metadata/directives.ts:113–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 * @publicApi
112 */
113export interface Directive {
114 /**
115 * The CSS selector that identifies this directive in a template
116 * and triggers instantiation of the directive.
117 *
118 * Declare as one of the following:
119 *
120 * - `element-name`: Select by element name.
121 * - `.class`: Select by class name.
122 * - `[attribute]`: Select by attribute name.
123 * - `[attribute=value]`: Select by attribute name and value.
124 * - `:not(sub_selector)`: Select only if the element does not match the `sub_selector`.
125 * - `selector1, selector2`: Select if either `selector1` or `selector2` matches.
126 *
127 * Angular only allows directives to apply on CSS selectors that do not cross
128 * element boundaries.
129 *
130 * For the following template HTML, a directive with an `input[type=text]` selector,
131 * would be instantiated only on the `<input type="text">` element.
132 *
133 * ```html
134 * <form>
135 * <input type="text">
136 * <input type="radio">
137 * <form>
138 * ```
139 *
140 */
141 selector?: string;
142
143 /**
144 * Enumerates the set of data-bound input properties for a directive
145 *
146 * Angular automatically updates input properties during change detection.
147 * The `inputs` property accepts either strings or object literals that configure the directive
148 * properties that should be exposed as inputs.
149 *
150 * When an object literal is passed in, the `name` property indicates which property on the
151 * class the input should write to, while the `alias` determines the name under
152 * which the input will be available in template bindings. The `required` property indicates that
153 * the input is required which will trigger a compile-time error if it isn't passed in when the
154 * directive is used.
155 *
156 * When a string is passed into the `inputs` array, it can have a format of `'name'` or
157 * `'name: alias'` where `name` is the property on the class that the directive should write
158 * to, while the `alias` determines the name under which the input will be available in
159 * template bindings. String-based input definitions are assumed to be optional.
160 *
161 * @usageNotes
162 *
163 * The following example creates a component with two data-bound properties.
164 *
165 * ```ts
166 * @Component({
167 * selector: 'bank-account',
168 * inputs: ['bankName', {name: 'id', alias: 'account-id'}],
169 * template: `
170 * Bank Name: {{bankName}}

Callers 15

SomeDirectiveClass · 0.90
MyDirClass · 0.90
MyDir1Class · 0.90
MyDir2Class · 0.90
TestDirClass · 0.90
MyDirectiveClass · 0.90
StandaloneDirectiveClass · 0.90
MyDirClass · 0.90
OptionalInputClass · 0.90
SomeDirClass · 0.90
BaseClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected