mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
parent
119eaa5651
commit
9977727f73
1 changed files with 5 additions and 5 deletions
|
|
@ -210,7 +210,7 @@ To combine property and event bindings using the banana-in-a-box syntax, `[()]`,
|
|||
## Additional Configurations
|
||||
### Configuring the child component input as required field
|
||||
|
||||
To make `Input` property as required for a child component while passing values from parent component. first import `Input` and then decorate the property with `@Input({ required: true })`, as in the following example.
|
||||
To make `Input` property as required for a child component while passing values from parent component, first import `Input` and then decorate the property with `@Input({ required: true })`, as in the following example:
|
||||
|
||||
<code-example header="src/app/item-details-metadata/item-details-metadata.component.ts" path="inputs-outputs/src/app/item-details-metadata/item-details-metadata.component.ts" region="use-input-metadata-required"></code-example>
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ Next, in the parent template add the following:
|
|||
|
||||
<code-example header="src/app/app.component.html" path="inputs-outputs/src/app/app.component.html" region="input-parent-metadata"></code-example>
|
||||
|
||||
If required inputs `property binding` in a child component are not specified in the parent component template will result a compile time error :
|
||||
If required inputs in a child component are not specified in the parent component template will result a compile time error:
|
||||
|
||||
<div class="alert is-helpful">
|
||||
NG8008: Required input item from component ItemDetailMetadataComponent must be specified.
|
||||
|
|
@ -226,13 +226,13 @@ NG8008: Required input item from component ItemDetailMetadataComponent must be s
|
|||
|
||||
### Configuring the child component input with transform functions
|
||||
|
||||
To transform an `Input` property from string to boolean to a child component while passing values from parent component. first import `booleanAttribute` and then decorate the property with `@Input({ transform: booleanAttribute })`, as in the following example.
|
||||
To transform an `Input` property from string to boolean to a child component while passing values from parent component. first import `booleanAttribute` and then decorate the property with `@Input({ transform: booleanAttribute })`, as in the following example:
|
||||
|
||||
<code-example header="src/app/item-details-metadata/item-details-metadata.component.ts" path="inputs-outputs/src/app/item-details-metadata/item-details-metadata.component.ts" region="use-input-metadata-boolean-transform"></code-example>
|
||||
|
||||
<code-example header="src/app/app.component.html" path="inputs-outputs/src/app/app.component.html" region="input-parent-metadata"></code-example>
|
||||
|
||||
Similarly, you can use predefined functions from angular/core library to convert string to number as well, see `numberAttribute`.
|
||||
Similarly, you can use predefined functions from the `angular/core` library to convert string to number as well, see `numberAttribute`.
|
||||
|
||||
<!-- links -->
|
||||
|
||||
|
|
@ -240,4 +240,4 @@ Similarly, you can use predefined functions from angular/core library to convert
|
|||
|
||||
<!-- end links -->
|
||||
|
||||
@reviewed 2022-02-28
|
||||
@reviewed 2023-08-20
|
||||
|
|
|
|||
Loading…
Reference in a new issue