Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,940 --> 00:00:05,440
We've now seen examples of how to get information into a template and how to get information out as
2
00:00:05,440 --> 00:00:06,430
well.
3
00:00:06,430 --> 00:00:07,840
We've seen property binding.
4
00:00:07,840 --> 00:00:11,420
Remember this is how we set some property on an element.
5
00:00:11,460 --> 00:00:15,940
It's property binding syntax we make use of those square brackets and then inside we put the name of
6
00:00:15,940 --> 00:00:18,910
the property that we want to set on that element.
7
00:00:18,920 --> 00:00:23,810
We also looked at event binding that has parentheses instead and inside the parentheses.
8
00:00:23,810 --> 00:00:24,910
We put the name of the event.
9
00:00:24,920 --> 00:00:28,590
We want to watch for then with both these pieces of syntax.
10
00:00:28,640 --> 00:00:34,310
We write out a set of double quotes then whatever goes inside there is going to be executed as code
11
00:00:35,300 --> 00:00:41,170
so we can reference different properties or methods that belong to our component class and there's one
12
00:00:41,200 --> 00:00:45,470
other very special part of syntax or piece of syntax so we need to understand.
13
00:00:45,700 --> 00:00:50,890
We've seen how to kind of get information as properties into specific elements but how do we also just
14
00:00:50,890 --> 00:00:56,350
kind of like print out a piece of information in general like display it as raw text that a user can
15
00:00:56,350 --> 00:00:57,340
see.
16
00:00:57,580 --> 00:01:02,420
Well there's one last piece of syntax we need to understand around templates to do so I'm going to go
17
00:01:02,420 --> 00:01:03,790
back over to my editor.
18
00:01:03,990 --> 00:01:09,500
I'm going to open up my app component A.T.M. file once again and then down at the very bottom right
19
00:01:09,500 --> 00:01:10,870
after that last div.
20
00:01:11,060 --> 00:01:14,860
I'm going to try to print out the value of our password property.
21
00:01:14,890 --> 00:01:20,450
So in this case I want to just print the value itself as opposed to applying it as a property to an
22
00:01:20,450 --> 00:01:21,500
existing element.
23
00:01:22,170 --> 00:01:25,960
So to do so we're gonna put in a set of double curly braces.
24
00:01:26,110 --> 00:01:31,700
Now we can write out the name of the property that we want to print from our component class.
25
00:01:31,760 --> 00:01:35,740
In this case I'll just write out password like so that once again.
26
00:01:35,740 --> 00:01:41,410
This right here takes a look at the password property of our component class whatever its value is is
27
00:01:41,410 --> 00:01:46,050
going to be stuck right there inside of our template let's save this.
28
00:01:46,050 --> 00:01:50,560
We'll go back over when our application first loads up.
29
00:01:50,600 --> 00:01:55,280
I don't see anything at the bottom that is because when our component class is first created the password
30
00:01:55,280 --> 00:01:57,730
property gets an initial value of empty string.
31
00:01:58,370 --> 00:02:03,290
But when we click on that generate button that updates the value of the password property it gives it
32
00:02:03,290 --> 00:02:09,370
that my password string or whatever it is going to click on the button and I'll see my password appear
33
00:02:09,410 --> 00:02:16,280
down here at the bottom so once again this is like total magic on the side of angular we just updated
34
00:02:16,310 --> 00:02:23,030
a property on our class and angular automatically detected that and then updated our each team L to
35
00:02:23,030 --> 00:02:27,620
accommodate that's pretty much total magic OK.
36
00:02:27,650 --> 00:02:32,840
So we've now seen how to react to events how to set properties on elements and how to print out plain
37
00:02:32,870 --> 00:02:34,550
information as well.
38
00:02:34,550 --> 00:02:41,370
The printing out information uses the double curly braces just like we saw with the property binding
39
00:02:41,850 --> 00:02:43,940
and the event binding as well.
40
00:02:44,190 --> 00:02:48,820
We are free to also call different methods on our class if we want to.
41
00:02:48,900 --> 00:02:50,840
For example back over inside of our class.
42
00:02:50,850 --> 00:02:58,790
If we added on some method inside of here called get a name write about just get name that's better.
43
00:02:59,120 --> 00:03:06,460
And I returned a string of like I don't know Alex I can now call this method from inside of those double
44
00:03:06,460 --> 00:03:08,100
curly braces.
45
00:03:08,100 --> 00:03:16,020
I will save this go back over once again I can reference get name and call it like a function I save
46
00:03:16,020 --> 00:03:22,420
this you can go back over and right away I will see Alex up here I want to remind you once again for
47
00:03:22,420 --> 00:03:28,600
the third time now we did not have to do this docket name we did not have to do app it name we didn't
48
00:03:28,600 --> 00:03:33,820
have to do component dot name we just wrote the name of the method from our component class that was
49
00:03:33,820 --> 00:03:35,870
it all right.
50
00:03:35,910 --> 00:03:41,810
Now we've seen these three forms of syntax event property and this is technically called interpolation
51
00:03:41,820 --> 00:03:42,650
by the way.
52
00:03:42,750 --> 00:03:47,010
That's pretty much the major core ideas of angular templates believe or not.
53
00:03:47,010 --> 00:03:52,440
Those three pieces of syntax that is the core things that you need to understand now that we've seen
54
00:03:52,440 --> 00:03:57,120
these three different forms of syntax one more pause are going to start to add in some more functionality
55
00:03:57,120 --> 00:04:02,430
to our app in just a moment but before we do really quickly I'm going to remove that example.
56
00:04:02,460 --> 00:04:06,660
I just wanted to show you how we get through plain information into the template.
57
00:04:06,680 --> 00:04:12,000
Now I'm also going to remove the get named method that I just added inside the component as well that's
58
00:04:12,010 --> 00:04:14,660
now quick pause more development in just a moment.
6433
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.