Return to site

🅰 NEW In Angular: Required for @Input

May 31, 2023

With Angular 16, you can use the {𝑟𝑒𝑞ð‘Ē𝑖𝑟𝑒𝑑:ð‘Ąð‘Ÿð‘Ē𝑒} option for an @𝐞𝑛𝑝ð‘Ēð‘Ą() decorator to make a property mandatory.

This means that the component will only work if you pass a value for that property.

ðŸ‘Ļ‍ðŸ’ŧïžĢïžŊïžĪïžĨ ïžģïžŪïžĐïž°ïž°ïžĨïžī

❌ïžĨïžēïžēïžŊïžē

If the name property of GreetingComponent is not filled, the error message will be something like this:

ðļ𝑟𝑟𝑜𝑟: 𝑀𝑖𝑠𝑠𝑖𝑛𝑔 𝑟𝑒𝑞ð‘Ē𝑖𝑟𝑒𝑑 @𝐞𝑛𝑝ð‘Ēð‘Ą() 𝑓𝑜𝑟 ð‘ð‘œð‘šð‘ð‘œð‘›ð‘’ð‘›ð‘Ą ðšð‘Ÿð‘’ð‘’ð‘Ąð‘–ð‘›ð‘”ðķð‘œð‘šð‘ð‘œð‘›ð‘’ð‘›ð‘Ą: 𝑛𝑎𝑚𝑒

#angular #angular16 #requiredInput #programming