Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,350 --> 00:00:06,510
Let's add in some code to make sure that we detect whenever user types inside that text input to do
2
00:00:06,510 --> 00:00:06,850
so.
3
00:00:06,870 --> 00:00:09,780
We're going to go back into our component template.
4
00:00:09,780 --> 00:00:12,840
That's our app component that HDMI file inside of here.
5
00:00:12,840 --> 00:00:18,350
We're going to find our input element and then on that element we're going to add an event binding.
6
00:00:18,660 --> 00:00:23,180
Remember we specify an event binding with parentheses inside the parentheses.
7
00:00:23,190 --> 00:00:26,050
We list out the event that we want to watch for.
8
00:00:26,090 --> 00:00:31,020
So in this case you want to watch for an input event which is triggered whenever user changes anything
9
00:00:31,020 --> 00:00:40,550
inside this input and whenever that occurs we will try calling a method called on input on our class.
10
00:00:40,600 --> 00:00:44,980
Remember that when we call on inputs or whatever method we call right here we probably want to communicate
11
00:00:44,980 --> 00:00:47,640
whatever user just entered into that text input.
12
00:00:47,810 --> 00:00:53,840
But to do so we need to refer to that event that target dot value property we can get access to the
13
00:00:53,840 --> 00:01:00,140
event object that is created whenever a user causes the input event by writing out dollar sign event
14
00:01:00,980 --> 00:01:05,660
and then on there we'll get the target which is a reference to the input element and then off there
15
00:01:06,020 --> 00:01:13,400
we'll get our value like so now you'll notice that this is all underlined inside red as because we don't
16
00:01:13,400 --> 00:01:17,410
have a method on our component class called on input.
17
00:01:17,450 --> 00:01:24,100
Let's go back over to our app computer right now and add that in over inside of app component.
18
00:01:24,120 --> 00:01:24,680
Yes.
19
00:01:24,780 --> 00:01:31,680
After we declare our random text will then add in the on input method this will be called with some
20
00:01:31,680 --> 00:01:38,390
value and we have to annotate its type as being a string then inside of here if we really want to follow
21
00:01:38,390 --> 00:01:44,150
the directions we want to make sure that we console log whatever that value is so inside that event
22
00:01:44,150 --> 00:01:55,290
handler will do a console log of value let's save this will float back over and test it out and get
23
00:01:55,410 --> 00:01:55,970
over here.
24
00:01:56,030 --> 00:02:01,460
I'm going to open up my console inside my browser and then I'll select the input and start typing messages
25
00:02:01,520 --> 00:02:07,160
as I do so I see the value inside the input with every single key press it looks like that worked out
26
00:02:07,160 --> 00:02:09,000
pretty well.
27
00:02:09,030 --> 00:02:12,030
All right let's now move on to our next step in this step.
28
00:02:12,030 --> 00:02:14,760
We're not going to do the character comparison right away.
29
00:02:14,760 --> 00:02:19,340
Instead we're going to start to handle that success message at the bottom of our application.
30
00:02:19,440 --> 00:02:24,800
This one right here right now that success message is always visible.
31
00:02:24,800 --> 00:02:27,600
I want you to make sure that the message gets hidden by default.
32
00:02:27,620 --> 00:02:34,520
When our application first starts up and then as soon as the user enters the exact correct text we're
33
00:02:34,520 --> 00:02:37,040
then going to show success on the screen.
34
00:02:37,040 --> 00:02:43,430
So after that we do want to in fact show that element right there go ahead and give that a shot.
35
00:02:43,470 --> 00:02:46,680
We'll take a quick pause right here and go over a solution in just a moment.
3982
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.