1 00:00:00,270 --> 00:00:06,330 In this lecture, we're going to learn how to add an alias for an input in our editors. 2 00:00:06,510 --> 00:00:10,350 Let's take a look inside the post component class file. 3 00:00:12,850 --> 00:00:19,780 We have a property called Post Image decorated with the input decorator, the parent component has the 4 00:00:19,780 --> 00:00:22,960 power to override this property with an attribute. 5 00:00:23,410 --> 00:00:26,770 Our attribute name should be short yet descriptive. 6 00:00:27,160 --> 00:00:34,300 Angular gives us the opportunity to modify the attribute name for the property with an alias, for example, 7 00:00:34,510 --> 00:00:36,400 instead of typing post image. 8 00:00:36,520 --> 00:00:39,160 We can shorten the attribute name to image. 9 00:00:39,550 --> 00:00:45,790 The property name can remain the same in the class inside the input decorator function. 10 00:00:45,880 --> 00:00:49,180 We can pass in an alias, for this example. 11 00:00:49,300 --> 00:00:51,430 Let's set the alias to image. 12 00:00:53,960 --> 00:00:58,430 The post image property will hold the image URL in this component. 13 00:00:58,730 --> 00:01:04,670 However, if a parent component sets this property, it must use the alias to bind it. 14 00:01:05,000 --> 00:01:07,430 Let's switch over to the app template. 15 00:01:10,160 --> 00:01:14,750 On the app post components, we are going to change the binding to image. 16 00:01:17,420 --> 00:01:19,640 Let's check out the app in the browser. 17 00:01:22,210 --> 00:01:29,410 The image will still work great input, Alia says, give us even more flexibility with how we assign 18 00:01:29,410 --> 00:01:30,820 names to properties. 19 00:01:31,030 --> 00:01:34,420 With that being said, it's not a feature we should use. 20 00:01:34,420 --> 00:01:40,750 Often in the resource section of this lecture, I provide a link to angular style guide. 21 00:01:41,380 --> 00:01:45,730 The style guide is a resource of opinionated ways to write code. 22 00:01:46,000 --> 00:01:48,460 It's not required to follow these rules. 23 00:01:48,940 --> 00:01:51,820 We do have the option of making our own rules. 24 00:01:52,150 --> 00:01:57,910 Angular provides the rules set for those who want to know what's considered good practice on a standard 25 00:01:57,910 --> 00:01:58,330 app. 26 00:01:58,840 --> 00:02:03,520 One of the rules will tell us to avoid aliases for inputs and outputs. 27 00:02:03,820 --> 00:02:06,910 We haven't had the chance to focus on outputs. 28 00:02:07,270 --> 00:02:10,060 It's a topic we'll explore in an upcoming lecture. 29 00:02:10,389 --> 00:02:14,930 For now, we will assume this rule applies to input decorators. 30 00:02:15,250 --> 00:02:18,400 According to the rule, we should avoid aliases. 31 00:02:18,670 --> 00:02:19,180 Why? 32 00:02:19,480 --> 00:02:24,550 It's because it can be confusing to memorize so many names for one value. 33 00:02:25,120 --> 00:02:27,100 Feel free to read up on this guide. 34 00:02:27,370 --> 00:02:29,830 We will be following some of these practices. 35 00:02:30,100 --> 00:02:32,830 I'll be sure to bring it up as often as I can. 36 00:02:33,100 --> 00:02:37,240 We won't be using aliases for our inputs throughout this course. 37 00:02:37,510 --> 00:02:41,860 I wanted to mention aliasing in case you come across it in a project. 38 00:02:42,160 --> 00:02:44,220 Let's continue in the next lecture.