In this lecture, we're going to learn how to add an alias for an input in our editors.
Let's take a look inside the post component class file.
We have a property called Post Image decorated with the input decorator, the parent component has the
power to override this property with an attribute.
Our attribute name should be short yet descriptive.
Angular gives us the opportunity to modify the attribute name for the property with an alias, for example,
instead of typing post image.
We can shorten the attribute name to image.
The property name can remain the same in the class inside the input decorator function.
We can pass in an alias, for this example.
Let's set the alias to image.
The post image property will hold the image URL in this component.
However, if a parent component sets this property, it must use the alias to bind it.
Let's switch over to the app template.
On the app post components, we are going to change the binding to image.
Let's check out the app in the browser.
The image will still work great input, Alia says, give us even more flexibility with how we assign
names to properties.
With that being said, it's not a feature we should use.
Often in the resource section of this lecture, I provide a link to angular style guide.
The style guide is a resource of opinionated ways to write code.
It's not required to follow these rules.
We do have the option of making our own rules.
Angular provides the rules set for those who want to know what's considered good practice on a standard
app.
One of the rules will tell us to avoid aliases for inputs and outputs.
We haven't had the chance to focus on outputs.
It's a topic we'll explore in an upcoming lecture.
For now, we will assume this rule applies to input decorators.
According to the rule, we should avoid aliases.
Why?
It's because it can be confusing to memorize so many names for one value.
Feel free to read up on this guide.
We will be following some of these practices.
I'll be sure to bring it up as often as I can.
We won't be using aliases for our inputs throughout this course.
I wanted to mention aliasing in case you come across it in a project.
Let's continue in the next lecture.