All language subtitles for 012 Sidebar Slot Properties_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,300 --> 00:00:01,980 Welcome to this sidebar. 2 00:00:01,980 --> 00:00:05,130 Sidebars are lectures you don't have to take immediately. 3 00:00:05,130 --> 00:00:08,010 It's a lecture you can revisit later whenever you want. 4 00:00:08,010 --> 00:00:12,060 It's not required to watch this lecture to continue on with the course. 5 00:00:12,060 --> 00:00:13,860 It's completely independent. 6 00:00:13,860 --> 00:00:18,030 I throw in sidebars to provide additional information about a topic. 7 00:00:18,060 --> 00:00:23,340 In this lecture we're going to discuss what slot properties are and how they work. 8 00:00:23,370 --> 00:00:26,880 They're a topic we're going to encounter in the next lecture. 9 00:00:26,880 --> 00:00:33,840 I want to use this opportunity to discuss what slot properties are before diving back into validation. 10 00:00:33,930 --> 00:00:37,350 We're going to be working on a separate project for this topic. 11 00:00:37,470 --> 00:00:43,770 In the resource section of this lecture, I provide a zip file, download it, install the packages 12 00:00:43,770 --> 00:00:45,360 and start the server. 13 00:00:45,510 --> 00:00:47,550 Pause the video if you need to. 14 00:00:49,830 --> 00:00:52,000 Let's quickly review the files. 15 00:00:52,020 --> 00:00:55,710 I generated the project with the default preset slot. 16 00:00:55,710 --> 00:00:57,990 Properties are a view feature. 17 00:00:57,990 --> 00:01:00,930 It's not required to install any other library. 18 00:01:00,930 --> 00:01:08,670 Aside from view, I've made modifications to two files the app and hello world component files. 19 00:01:08,670 --> 00:01:10,770 We'll start with the app component. 20 00:01:11,010 --> 00:01:15,840 Inside this file we're importing and registering the Hello World component. 21 00:01:15,870 --> 00:01:18,600 There's nothing else going on in the script block. 22 00:01:18,600 --> 00:01:24,240 In the template block we're using the Hello World component with opening and closing tags. 23 00:01:24,240 --> 00:01:29,730 We're going to add slots to the component, so we'll need to use opening and closing tags. 24 00:01:30,090 --> 00:01:32,340 Open the Hello World component. 25 00:01:34,390 --> 00:01:37,890 The template block has an empty set of div tags. 26 00:01:37,900 --> 00:01:44,410 We're going to add slots to it in a moment in the script block the data function is defined. 27 00:01:44,440 --> 00:01:48,160 There are two properties called user and favorites. 28 00:01:48,160 --> 00:01:52,060 The user property contains random information about a user. 29 00:01:52,060 --> 00:01:55,690 The favorites property is a list of their favorite things. 30 00:01:55,960 --> 00:01:59,380 The data is not being used anywhere in the application. 31 00:01:59,380 --> 00:02:02,080 You can safely ignore it for the time being. 32 00:02:02,080 --> 00:02:03,490 We'll get to it soon. 33 00:02:03,520 --> 00:02:07,540 The objective is to add slots to the Hello World component. 34 00:02:07,540 --> 00:02:13,150 This way we can allow for content to be inserted in between the div tags. 35 00:02:13,150 --> 00:02:14,860 Add the slot component. 36 00:02:17,090 --> 00:02:19,180 We're not going to assign it a name. 37 00:02:19,190 --> 00:02:21,380 It's going to be the default slot. 38 00:02:21,410 --> 00:02:26,540 Let's switch over to the app component file to insert some content inside. 39 00:02:26,540 --> 00:02:32,750 The Hello World component will add a paragraph element with the following message Hello World. 40 00:02:34,960 --> 00:02:40,080 This will result in the message appearing in the slot we have in the hello world component. 41 00:02:40,090 --> 00:02:42,880 Switch over to the browser to view the message. 42 00:02:45,170 --> 00:02:47,250 It's getting inserted like we wanted. 43 00:02:47,270 --> 00:02:48,120 That's great. 44 00:02:48,140 --> 00:02:50,260 We'll want to take it to the next level. 45 00:02:50,270 --> 00:02:54,090 Back in, the editor will want to make the content more dynamic. 46 00:02:54,110 --> 00:02:55,760 The message is static. 47 00:02:55,790 --> 00:02:59,330 It would be great if we could update the message to greet the user. 48 00:02:59,360 --> 00:03:03,860 The user information is stored in the Hello World component. 49 00:03:04,250 --> 00:03:10,160 Theoretically, we can move the data from the Hello World component to the app component. 50 00:03:10,190 --> 00:03:12,890 However, there is an alternative approach. 51 00:03:12,890 --> 00:03:15,540 We can take a much more flexible one. 52 00:03:15,560 --> 00:03:20,330 We can use slot properties to pass information to a slot children. 53 00:03:20,360 --> 00:03:24,490 Let's look at how that's done in the Hello World component. 54 00:03:24,500 --> 00:03:27,650 We're going to bind a property to the slot component. 55 00:03:27,650 --> 00:03:29,780 We'll call the property user. 56 00:03:32,420 --> 00:03:39,470 The value for this will be the user property we have in the data object by binding a property to the 57 00:03:39,470 --> 00:03:40,620 slot component. 58 00:03:40,640 --> 00:03:43,130 It will become available in the parent scope. 59 00:03:43,160 --> 00:03:46,850 In this example, the parent scope is the app component. 60 00:03:47,180 --> 00:03:49,670 We'll switch back to the app component. 61 00:03:50,120 --> 00:03:56,330 If we would like to use the user object in the content, we need to add the the slot property to the 62 00:03:56,330 --> 00:03:58,520 hello world component in the template. 63 00:04:00,880 --> 00:04:05,730 The V slot property requires an alias for the list of slot properties. 64 00:04:05,740 --> 00:04:07,330 We're going to call it V. 65 00:04:09,770 --> 00:04:14,870 The V alias will represent every property bounced to the slot component. 66 00:04:15,560 --> 00:04:19,209 Binding one property which is the user data object. 67 00:04:19,220 --> 00:04:21,170 We can use it in our content. 68 00:04:21,200 --> 00:04:27,230 I'm going to replace the word world with the expression v dot user name. 69 00:04:29,620 --> 00:04:33,320 The name we selected for the alias is entirely optional. 70 00:04:33,340 --> 00:04:37,060 It's common practice to name it V or slot props. 71 00:04:37,090 --> 00:04:38,740 Let's give things a test. 72 00:04:38,740 --> 00:04:41,290 Switch over to the browser to view the app. 73 00:04:43,500 --> 00:04:47,200 On the page, we can see that the message has been updated. 74 00:04:47,220 --> 00:04:49,340 It's greeting the user by their name. 75 00:04:49,350 --> 00:04:52,230 This output is precisely what we wanted. 76 00:04:52,260 --> 00:04:56,340 Slant properties allow you to send data to the parent scope. 77 00:04:56,370 --> 00:05:00,960 There are a couple more things I want to go over in regards to slot properties. 78 00:05:00,990 --> 00:05:06,210 First, the the slot directive is available in versions 2.6 and up. 79 00:05:06,240 --> 00:05:08,850 It's a new syntax feature added to view. 80 00:05:08,880 --> 00:05:12,420 It simplifies the process of using slot properties. 81 00:05:12,450 --> 00:05:16,980 Secondly, there's a shorthand syntax for using slot properties. 82 00:05:17,010 --> 00:05:19,290 Let's go back to the editor to use it. 83 00:05:19,320 --> 00:05:24,390 We can altogether remove the V slot directive from the Hello World component. 84 00:05:24,420 --> 00:05:27,690 The shorthand syntax is the LB character. 85 00:05:29,970 --> 00:05:35,100 We're required to set the name of the slot after the pound character by default. 86 00:05:35,100 --> 00:05:38,720 If we don't set a name for our slot, it'll be set to default. 87 00:05:38,730 --> 00:05:41,640 We'll need to add default after the pound. 88 00:05:43,940 --> 00:05:48,860 Another handy feature of slot properties is being able to structure the object. 89 00:05:48,890 --> 00:05:52,990 You can bind as many properties to the slot component as you'd like. 90 00:05:53,000 --> 00:05:55,820 If you're only going to use one or two properties. 91 00:05:55,820 --> 00:06:01,970 You may want to consider structuring the object, all the structure, the object to retrieve the user 92 00:06:01,970 --> 00:06:02,840 property. 93 00:06:05,030 --> 00:06:10,010 Then in the template block, we'll update the expression to user name. 94 00:06:12,280 --> 00:06:15,460 This can hopefully shorten some of the code you have to write. 95 00:06:15,460 --> 00:06:18,760 Lets view the browser to check for breaking changes. 96 00:06:21,020 --> 00:06:22,610 The name still gets rendered. 97 00:06:22,640 --> 00:06:25,000 There's not much else to slot properties. 98 00:06:25,010 --> 00:06:29,580 You can create as many slot properties as you'd like back in the editor. 99 00:06:29,600 --> 00:06:32,310 Let's switch to the Hello World component. 100 00:06:32,330 --> 00:06:39,650 As an exercise, try binding the favorites data property to the default slot, then use it in the app 101 00:06:39,650 --> 00:06:40,430 component. 102 00:06:40,430 --> 00:06:42,590 Pause the video and give it a try. 103 00:06:44,540 --> 00:06:45,550 Welcome back. 104 00:06:45,560 --> 00:06:49,030 If you are able to add a new slot property then congrats. 105 00:06:49,040 --> 00:06:50,890 If not, that's fine as well. 106 00:06:50,900 --> 00:06:52,220 We'll do it together. 107 00:06:52,250 --> 00:06:54,470 Open the Hello World component. 108 00:06:54,470 --> 00:06:58,760 We'll bind a property called Favorites to the slot component. 109 00:06:58,790 --> 00:07:01,580 Its value will be set to favorites. 110 00:07:03,750 --> 00:07:06,730 By the way, you don't have to keep the names the same. 111 00:07:06,750 --> 00:07:08,890 You can call this whatever you want. 112 00:07:08,910 --> 00:07:12,450 I recommend keeping the names the same for consistency. 113 00:07:12,750 --> 00:07:16,600 The favorites data property is available in the parent scope. 114 00:07:16,620 --> 00:07:17,650 Let's use it. 115 00:07:17,670 --> 00:07:21,510 Switch to the app component file in the template block. 116 00:07:21,510 --> 00:07:25,260 We'll need to de structure the favorites property from the object. 117 00:07:27,570 --> 00:07:30,270 It's important to structure the object. 118 00:07:30,300 --> 00:07:33,990 Otherwise we won't be able to access the favourites array. 119 00:07:34,020 --> 00:07:37,980 After restructuring the array, we're going to add on to the message. 120 00:07:37,980 --> 00:07:40,170 I like favorites zero. 121 00:07:44,420 --> 00:07:50,150 The favourites data property is an array where accessing the first item in the array. 122 00:07:50,180 --> 00:07:52,830 If you'd like, you can loop through the items. 123 00:07:52,850 --> 00:07:56,600 We'll keep it simple by outputting the first item in the array. 124 00:07:56,630 --> 00:07:58,580 Let's use the app in the browser. 125 00:08:00,850 --> 00:08:04,300 The message renders the first item in the favorites array. 126 00:08:04,330 --> 00:08:05,240 That's great. 127 00:08:05,260 --> 00:08:08,520 We've successfully learned how slot properties work. 128 00:08:08,530 --> 00:08:11,770 They're handy for passing on data to the parent scope. 129 00:08:11,770 --> 00:08:18,340 In the resource section of this lecture, I provide a link to the scoped slots documentation page. 130 00:08:21,120 --> 00:08:25,920 This page will provide you with more information and examples of slot properties. 131 00:08:25,950 --> 00:08:29,340 I recommend reading it after you finished this lecture. 132 00:08:29,370 --> 00:08:33,929 In the next lecture we will continue with form validation in our project. 12204

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.