All language subtitles for 14. Accessing Elements from a Custom Directive

af Afrikaans
ak Akan
sq Albanian
am Amharic
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

Original subtitles

Now that we have our directive generated I want to give you a very quick example and show you how we

can kind of play around with the elements.

Do we apply the directive to the we're going to rebuild a very classic example of directives that you

see inside of like every angular tutorial ever including the official documentation.

I want to very briefly we're going to change the class directive but very briefly we're going to make

our class directive apply a background color to whatever element we apply the directive to.

But this is just going to help us understand how we can actually access the elements that we apply the

directive to and how we can change some properties on it to get started at the very top.

I'm going to import something called Element ref and then on the constructor I'm going to write in private

element is of type element ref like So what does this element thing listeners we add in this argument.

Angela's going to make sure that whenever we create an instance of class directive a first argument

to the constructor is going to be the element that we applied the directive to then the words this element

right here is pretty much a direct reference to that Ally lie right there we can access this element

property and start to mess around with some of the underlying properties on the actual HDL element.

For example we can start to add in some different styling rules and whatnot.

We can modify some classes on it all that kind of good stuff.

So instead of doing a cuts lug I'm going to instead reference this dot element and here's the one gotcha

here.

This dot element is not the actual H T.M. element to actually get the HMO element.

We have to access a little property inside of element called eighth element.

This native element thing that is the actual each small element we care about.

Keep in mind as you start to access that element then on there we can mess around with that element

in any way that we would normally mess around with each team L from some javascript code for example

we can set a style on there or something like that but to set a style you could say style dots background

lowercase G background color is about orange except now by save this and flip back over I'll see it's

really hard to see here.

I'm going to zoom in really really far.

You'll notice that Yeah right there.

Look at that.

Yeah that's orange.

See that orange background color.

Okay maybe that was a bad place to apply this directive though let's try applying that directive to

instead the H or element that we're creating right there at the beach.

So it is working it's just really hard to see that background.

We're gonna go back over my template to remove app class from the ally and then go down to the H four

down here and apply hub class there instead of look back over Yeah there we go now it's orange was orange

before but now you can actually see that it's orange.

OK.

So that's how we just reach into some directive how we get access to the elements.

Now we just mess around at the element in some fashion.

Oh pretty basic pretty straightforward but obviously this is not super useful is if we want to apply

a background color of wants to an element Well we're just going to use some CSX we're not gonna write

a custom directed for that nonetheless at least we understand how to reach out and grab an element.

Let's take another pause right here.

When come back the next video we're gonna figure out how we can receive some arguments into our directive

as well.

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