All language subtitles for 9. Styling by Comparison

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
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
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:01,470 --> 00:00:01,770 All right. 2 00:00:01,770 --> 00:00:06,120 Now that we've seen one hundred percent that we can compare these two characters by each other or at 3 00:00:06,120 --> 00:00:07,970 least we can get access to them. 4 00:00:08,010 --> 00:00:10,860 I'm going to remove the extra stuff inside of here. 5 00:00:10,980 --> 00:00:15,180 Specifically I'm going to take out that opening parentheses going to take out the closing parentheses 6 00:00:15,540 --> 00:00:18,260 and I don't really need to print out entered text at I anymore. 7 00:00:18,270 --> 00:00:24,050 I just did that to prove that we could take a look at a specific character inside of that property. 8 00:00:24,050 --> 00:00:30,170 So now I'm back to just printing out the single letter if I say this I should be back to seeing just 9 00:00:30,170 --> 00:00:32,130 the sentence by itself. 10 00:00:32,170 --> 00:00:37,120 Now the last thing we really need to do year is to make sure that we compare that letter with whatever 11 00:00:37,140 --> 00:00:39,080 is that entered text at I. 12 00:00:39,300 --> 00:00:43,880 And depending upon whether those things are the same or different we need to apply some styling to the 13 00:00:43,880 --> 00:00:47,550 span there's two ways we can help this. 14 00:00:47,550 --> 00:00:53,340 We could either tried to apply some direct styling rules to the span element or we can try to apply 15 00:00:53,370 --> 00:00:59,850 a class to it instead in our case we're going to try to apply a class to it though in order to apply 16 00:00:59,850 --> 00:01:05,220 a class to this band right here and have it be kind of a direct computation of a comparison between 17 00:01:05,220 --> 00:01:07,450 a letter and enter text at I. 18 00:01:07,590 --> 00:01:14,640 We're going to use property binding though I want to set the last property on the span and I want to 19 00:01:14,640 --> 00:01:16,500 do it using some code. 20 00:01:16,680 --> 00:01:19,450 That's why I'm going to use the binding syntax right here. 21 00:01:19,560 --> 00:01:23,730 Remember as soon as we add on those square brackets Whatever's inside of those double quotes will be 22 00:01:23,730 --> 00:01:27,690 evaluated as code for inside there. 23 00:01:27,720 --> 00:01:33,890 What we really want to do is a comparison between the letter and like entered text at I. 24 00:01:33,910 --> 00:01:37,400 Now the only reason I'm writing it out like this is to just make sure it's really clear. 25 00:01:37,500 --> 00:01:42,350 These are the two things that we want to compare and when we compare these two things there's really 26 00:01:42,350 --> 00:01:44,210 three different outcomes. 27 00:01:44,210 --> 00:01:50,330 The first outcome is a user might have not entered anything for entered text yet the user hasn't entered 28 00:01:50,330 --> 00:01:51,140 anything there. 29 00:01:51,140 --> 00:01:56,990 In other words if they haven't like entered any text at all then what we probably want to show is like 30 00:01:56,990 --> 00:01:58,640 the black text right there. 31 00:01:58,640 --> 00:02:01,370 That is one possible outcome of the comparison. 32 00:02:01,370 --> 00:02:04,730 The next possible outcome is if these two are different characters. 33 00:02:04,820 --> 00:02:05,650 That's another. 34 00:02:05,800 --> 00:02:06,690 And then if they're the same. 35 00:02:06,710 --> 00:02:09,610 That is a third though in doing this comparison right here. 36 00:02:09,620 --> 00:02:16,270 We're really talking about getting one of three different class names applied to the span to style it. 37 00:02:16,580 --> 00:02:21,200 Now adding in all the logic right here to handle those three different outcomes that would be really 38 00:02:21,200 --> 00:02:26,390 challenging to read rather than writing out the entire comparison right there inside this little block. 39 00:02:26,540 --> 00:02:31,580 I'm going to instead call a method on my app component class. 40 00:02:31,580 --> 00:02:36,350 I'm going to pass in the entered text like these specific character and the letter that we are currently 41 00:02:36,350 --> 00:02:41,210 iterating over then inside this method we're gonna do our comparison and then return the appropriate 42 00:02:41,210 --> 00:02:48,230 class name but remember inside of property binding syntax or interpolation string syntax and so on we 43 00:02:48,230 --> 00:02:51,400 can call any method that we want to on our class. 44 00:02:51,470 --> 00:02:55,280 And so I'm going to take care or I'm going to take advantage of that for determining the class name 45 00:02:55,330 --> 00:02:57,690 that we want to make use of right here. 46 00:02:57,700 --> 00:03:03,800 Now if you did not do this if you did not define a method on the class that is a 100 percent just fine. 47 00:03:03,820 --> 00:03:06,540 I really did not expect you to do so. 48 00:03:06,550 --> 00:03:13,840 Hundred percent did not expect it if you did not add a method on really don't feel bad whatsoever OK. 49 00:03:13,870 --> 00:03:18,910 So long story short when we do our property binding right here I'm going to try to call a method of 50 00:03:19,620 --> 00:03:20,080 it. 51 00:03:20,080 --> 00:03:22,870 Class How about a better name. 52 00:03:22,890 --> 00:03:25,700 Let's just call it compare stats we're really doing here. 53 00:03:25,740 --> 00:03:30,990 So when we call the compare method I can pass in the letter that we are currently iterating over and 54 00:03:31,110 --> 00:03:37,590 entered text at I then we'll go back over to our app components are going to implement that compare 55 00:03:37,590 --> 00:03:47,400 method back over here I'm going to add in the compare method and then our first argument to this thing 56 00:03:47,940 --> 00:03:53,730 is going to be the character that the user is me and the character that was generated so I'll call that 57 00:03:53,730 --> 00:04:02,850 thing generated actually about just random letter will be direct here and I'm got to say that's a string 58 00:04:03,760 --> 00:04:07,740 and then there is the entered letter and that's a string. 59 00:04:07,740 --> 00:04:09,780 So again there's three possible outcomes here. 60 00:04:09,870 --> 00:04:15,090 We're gonna first check to see if a user has entered a letter for this particular spot just yet. 61 00:04:15,090 --> 00:04:21,960 So if there is not an entered letter if one was not entered yet that means that a user has not yet typed 62 00:04:21,960 --> 00:04:23,090 out the rest of the string. 63 00:04:23,130 --> 00:04:27,810 And so we should probably return some class that's just going to color this as like gray or something. 64 00:04:27,990 --> 00:04:35,540 I'm going to return a string of how about pending but this string right here whatever you return from 65 00:04:35,540 --> 00:04:40,150 this function is going to be applied as the class name to the span elements. 66 00:04:40,340 --> 00:04:47,090 Right now when I return pending I'm saying I'm going to apply a pending class to that span. 67 00:04:47,130 --> 00:04:51,170 Next up we can check to see if a user entered the correct one or the incorrect one. 68 00:04:51,300 --> 00:04:57,540 We can either do that with some comparisons like we could say if entered letter is equal to random letter 69 00:04:58,740 --> 00:05:05,570 then return wrecked another more direct way to do this would be to use a ternary expression. 70 00:05:05,570 --> 00:05:10,610 We could say return random letter equal to entered. 71 00:05:10,630 --> 00:05:17,630 Letter and I'll put down a question mark though if this is true if random letters equal to edit will 72 00:05:17,660 --> 00:05:26,330 enter a letter and I want to return a string of rect otherwise I'll return a string of incorrect and 73 00:05:26,380 --> 00:05:28,270 so again that's a Turner expression. 74 00:05:28,270 --> 00:05:33,760 The question mark is where we separate the thing and say if that is true the return that otherwise give 75 00:05:33,760 --> 00:05:36,150 us that this is not typescript right here by the way. 76 00:05:36,160 --> 00:05:39,410 This is just normal javascript okay. 77 00:05:39,450 --> 00:05:40,780 Let's now save this. 78 00:05:40,790 --> 00:05:47,630 I'm going to go back over and tested out the back over if I open up my element Inspector. 79 00:05:47,670 --> 00:05:52,740 I'll now see that every element has a class of pending that means that I have not entered anything for 80 00:05:52,740 --> 00:05:54,020 these bands just yet. 81 00:05:54,210 --> 00:05:58,350 But as I start to type in here character by character we'll see all the different class name starts. 82 00:05:58,350 --> 00:06:04,600 UPDATE As soon as I put in a capital V which is correct I see the class name update to correct as well. 83 00:06:04,620 --> 00:06:05,810 Well then put in the next couple. 84 00:06:05,810 --> 00:06:11,790 Correctly open in a couple of incorrectly and I'll see very quickly that those also get marked as incorrect 85 00:06:12,510 --> 00:06:16,970 nonetheless and we really have to do here is add in some classes and RC SS file and style. 86 00:06:17,010 --> 00:06:24,170 Each of these things based on the class names will go to my app component c s ss file year app component 87 00:06:24,180 --> 00:06:30,990 Nazi SS and then inside of here we're gonna add in some selectors for pending correct and incorrect. 88 00:06:31,230 --> 00:06:37,030 So first off pending if we have an element with a class of pending I'm gonna give it a color of gray 89 00:06:38,200 --> 00:06:46,180 if we've got one with a rect class I'll add on a color of green and I'll also add in a font weight of 90 00:06:46,240 --> 00:06:52,470 bolt and then finally if we have an incorrect I'll put in a color of red. 91 00:06:52,490 --> 00:06:54,490 Like so you know what. 92 00:06:54,490 --> 00:06:58,120 Maybe just to make sure it's really clear to the user when they enter and a character incorrectly. 93 00:06:58,210 --> 00:07:01,570 I'm going to take the font weight and I'll move it over to incorrect. 94 00:07:01,570 --> 00:07:05,300 So we kind of highlight when a user enters something incorrectly. 95 00:07:05,330 --> 00:07:05,550 All right. 96 00:07:05,580 --> 00:07:06,800 Let's save this. 97 00:07:06,810 --> 00:07:09,770 I'm gonna flip back over and we'll do a quick test. 98 00:07:09,770 --> 00:07:14,270 Now I can see that every character starts off as grey meaning we still need to visit this character 99 00:07:14,980 --> 00:07:20,510 and if I enter DL o r e correctly each character starts to turn green. 100 00:07:20,630 --> 00:07:26,000 Then if I start to enter stuff incorrectly it all starts to turn red at any point time. 101 00:07:26,000 --> 00:07:28,330 I can't continue to start entering the correct character. 102 00:07:28,360 --> 00:07:31,530 So right now I need to enter an I.T. if I do so. 103 00:07:31,670 --> 00:07:35,840 Those do show up as green and so I'd have to go back to all these previous characters and fix those 104 00:07:35,840 --> 00:07:36,860 up. 105 00:07:36,860 --> 00:07:38,840 Well I'd say this looks pretty good. 106 00:07:38,840 --> 00:07:42,780 If I now entering the full string correctly I'm gonna do a copy paste here. 107 00:07:42,950 --> 00:07:46,470 Everything turns green and I get the success message at the bottom. 108 00:07:46,580 --> 00:07:50,750 While I'd say this looks pretty good on its last step I know it's kind of challenging to understand 109 00:07:51,350 --> 00:07:56,540 especially because we added in the call to a method on our class which is something we've definitely 110 00:07:56,540 --> 00:07:57,940 not really done before. 111 00:07:57,980 --> 00:08:03,110 Again if you did not add that part in absolutely no problem whatsoever and if you got stuck entirely 112 00:08:03,110 --> 00:08:04,100 on a step. 113 00:08:04,100 --> 00:08:05,200 Also no problem whatsoever. 114 00:08:05,200 --> 00:08:08,150 This really was a challenging little application. 115 00:08:08,150 --> 00:08:12,980 I just wanted to kind of push you a little bit and get you to try some different things out all right. 116 00:08:13,010 --> 00:08:14,670 So that is it for this application. 117 00:08:14,690 --> 00:08:18,860 I hope you enjoy putting this thing together step by step and at the very end here we've got a fun little 118 00:08:18,860 --> 00:08:24,380 application where we can write out the sentence a quick little typing test and so on. 119 00:08:24,520 --> 00:08:28,850 Though we still got a lot to learn about TypeScript and angular so click pause right here and I'll see 120 00:08:28,850 --> 00:08:29,810 you in just a minute. 13174

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