All language subtitles for 12. NgSwitch

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,890 --> 00:00:03,940 In this video we're going to take a look at another structural directive. 2 00:00:03,940 --> 00:00:08,310 This one is somewhat similar to energy if but it's just a little bit more complex. 3 00:00:08,440 --> 00:00:13,510 Now unfortunately I don't really see a good way of working in this directive to this application in 4 00:00:13,510 --> 00:00:14,870 a very natural fashion. 5 00:00:14,890 --> 00:00:19,090 So instead we're going to put together a couple of additional elements down here at the bottom to show 6 00:00:19,090 --> 00:00:20,920 you exactly how this directive works. 7 00:00:20,950 --> 00:00:25,020 It's kind of one of the scenarios where you'll know when you need this directive. 8 00:00:25,050 --> 00:00:25,290 OK. 9 00:00:25,320 --> 00:00:29,740 So I can go down to the bottom of my template and a comment out the div down there just so we don't 10 00:00:29,740 --> 00:00:34,300 have the giant image hogging up the screen and I'll show you exactly what we're going to be doing here. 11 00:00:34,960 --> 00:00:37,820 I'm going to place a div ON IT. 12 00:00:37,820 --> 00:00:43,960 I'M GONNA PUT ON SOMETHING CALLED THE ENERGY switch directive inside this energy switch directive. 13 00:00:43,980 --> 00:00:47,700 We're gonna produce or directly throw in some kind of value. 14 00:00:47,910 --> 00:00:53,370 When I say produce that means that we could call a method on our class that I could like say oh a method 15 00:00:53,370 --> 00:00:58,740 on here or refer to some property for example maybe you want to take a look at whatever the current 16 00:00:58,740 --> 00:01:06,980 value of current pages I could reference current page and inside this div we're gonna place a couple 17 00:01:06,980 --> 00:01:11,990 of other elements and on each of these elements we're going to apply the structural directive called 18 00:01:11,990 --> 00:01:14,420 the Energy switch case. 19 00:01:14,750 --> 00:01:23,560 I'm gonna put in a div here with Star Energy which case now angular is gonna take a look at whatever 20 00:01:23,560 --> 00:01:29,080 is produced by this expression right here and then going to take a look at all the elements inside that 21 00:01:29,080 --> 00:01:34,660 have this energy switch case directive on it it's gonna look at the value provided to each of them if 22 00:01:34,660 --> 00:01:40,060 the result of current page matches whatever we stick inside here then this element will be displayed 23 00:01:40,700 --> 00:01:46,630 for example if we stick in value 0 that means that this element will only be displayed when current 24 00:01:46,630 --> 00:01:55,850 page is equal to zero Let's try putting some message inside there I'll say Grant age is zero I'll save 25 00:01:55,850 --> 00:02:01,300 this in a flip back over by default our current page is zero that's how our application starts out and 26 00:02:01,310 --> 00:02:06,950 as soon as I go to the next page that message goes away because no longer is current page matching the 27 00:02:06,950 --> 00:02:13,120 value zero we can add in as many elements with energy switch case inside of here as you want I could 28 00:02:13,120 --> 00:02:22,690 have one or like two and 1 4 3 current pages to read pages 3 and so on it sounds skipping over one here. 29 00:02:22,810 --> 00:02:24,190 No particular reason. 30 00:02:24,360 --> 00:02:27,300 Now if I flip back over I get current pages zero. 31 00:02:27,300 --> 00:02:31,460 Now I want to go up to page 2 or really current page of number 1. 32 00:02:31,570 --> 00:02:33,480 I don't have any matching switch case. 33 00:02:33,580 --> 00:02:40,270 So I see no message as I go on to the next one that I see current pages 2 and current page is 3. 34 00:02:40,300 --> 00:02:44,760 Like I said this is one of those directives where you're probably going to know when you need it. 35 00:02:44,800 --> 00:02:49,090 As I mentioned it just doesn't quite work in naturally to the application working on right now. 36 00:02:49,270 --> 00:02:51,190 There is one last thing I won't mention here. 37 00:02:51,220 --> 00:02:56,530 Here's another very tightly coupled directive that works with these to put it at the bottom. 38 00:02:56,530 --> 00:02:59,040 I'll put in Star Energy switch. 39 00:02:59,170 --> 00:03:07,100 Default I you can imagine what this does if none of these different cases right here match the original 40 00:03:07,100 --> 00:03:12,660 value that we produced then instead it will show what is whatever is inside of this element. 41 00:03:12,660 --> 00:03:20,610 But in this case inside here I'll say unknown burnt H now I'll save this and I'll expect to see this 42 00:03:20,610 --> 00:03:25,750 message appear whenever current page is not equal to zero 2 or 3. 43 00:03:27,000 --> 00:03:28,520 Flip back over. 44 00:03:28,520 --> 00:03:29,080 I now see. 45 00:03:29,090 --> 00:03:30,800 Right here we don't have a case to handle this. 46 00:03:30,830 --> 00:03:36,620 So we see unknown current page you'll see current pages to read and I get back to unknown current page 47 00:03:36,890 --> 00:03:39,720 for all the rest of the pages inside of here. 48 00:03:39,800 --> 00:03:42,430 That is pretty much it for energy switch. 49 00:03:42,620 --> 00:03:48,110 Now last thing I want you to understand here is that if we have multiple matching cases they're all 50 00:03:48,110 --> 00:03:49,420 going to be displayed. 51 00:03:49,610 --> 00:03:53,380 In other words if I change the switch case to zero and zero. 52 00:03:53,570 --> 00:03:55,090 Now in every current page is zero. 53 00:03:55,100 --> 00:03:56,750 These will all be displayed. 54 00:03:56,780 --> 00:04:00,670 That might sound kind of worthless but there actually are scenarios where you might want to have like 55 00:04:00,680 --> 00:04:03,870 different elements inside of your or different sets of elements. 56 00:04:03,980 --> 00:04:10,320 Go off or on whenever some value is equal to something as we can try that and we'll see. 57 00:04:10,320 --> 00:04:12,920 Yup shows 0 2 and 3. 58 00:04:12,930 --> 00:04:16,540 If you have multiple matching statements they will all be displayed. 59 00:04:16,610 --> 00:04:19,140 OK so like I said that is pretty much it for energy switch. 60 00:04:19,170 --> 00:04:22,930 All you have to remember is energy switch which case and switch default. 61 00:04:24,020 --> 00:04:24,390 All right. 62 00:04:24,420 --> 00:04:25,470 Let's take a pause right here. 63 00:04:25,500 --> 00:04:30,420 When we come back the next video we're gonna take a look at how we can build our own custom structural 64 00:04:30,420 --> 00:04:31,420 directive. 65 00:04:31,440 --> 00:04:33,290 A quick pause and I'll see you in just a minute. 7018

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