Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,340 --> 00:00:01,640
All right.
2
00:00:01,670 --> 00:00:06,330
Let's make sure that we can hide or display that success message at the bottom the screen.
3
00:00:06,380 --> 00:00:09,170
Remember that's the exercise that we just laid out.
4
00:00:09,170 --> 00:00:12,190
There's definitely many different ways we can accomplish this.
5
00:00:12,200 --> 00:00:14,660
I'm going to show you what you probably came up with.
6
00:00:14,720 --> 00:00:17,520
You probably came up one of two different ways.
7
00:00:17,600 --> 00:00:22,130
So I got to show you one way and then as we are implementing this I will mention another way that you
8
00:00:22,130 --> 00:00:24,740
very likely might have implemented this as well.
9
00:00:24,920 --> 00:00:29,850
Either approach that I'm going to show you or mention really quickly is 100 percent appropriate though.
10
00:00:29,870 --> 00:00:31,230
Let's get to it.
11
00:00:31,280 --> 00:00:34,190
I mean first begin inside of my app component class.
12
00:00:34,280 --> 00:00:38,920
So essentially we want to take a look whenever this event handler right here gets called.
13
00:00:39,110 --> 00:00:41,690
You want to look at the value that the user has entered.
14
00:00:41,790 --> 00:00:46,910
And if a user entered a value that is equal to random text and we want to communicate that into our
15
00:00:46,910 --> 00:00:53,120
template and specifically we want to either hide or show this div down here along with the H1 inside
16
00:00:53,120 --> 00:00:53,390
of it
17
00:00:56,340 --> 00:01:01,350
the first way that we could do that is by taking the value that a user has entered and storing it as
18
00:01:01,380 --> 00:01:03,790
a property on our components.
19
00:01:03,790 --> 00:01:10,560
So for example I could define a new property called entered text and default it to be an empty string
20
00:01:12,200 --> 00:01:16,940
and whenever on input gets called I can update the value of enter text.
21
00:01:16,950 --> 00:01:23,630
Let's say this not entered text equals value whenever we update a property on the class that is going
22
00:01:23,630 --> 00:01:29,630
to cause our template to automatically update itself so we can now go back over to our template and
23
00:01:29,630 --> 00:01:35,750
down on that div at the very bottom we can compare the enter text property against random text and then
24
00:01:35,750 --> 00:01:40,120
if they are identical we can either show or hide the message at the bottom.
25
00:01:40,130 --> 00:01:43,720
Now remember there is another way that you very likely might have taken care of this.
26
00:01:43,730 --> 00:01:48,920
I will mention that in just a moment they will now go back over I'll find the div at the very bottom
27
00:01:49,430 --> 00:01:54,900
and remember to conditionally show or hide some content we can use that energy for DirecTV.
28
00:01:55,190 --> 00:02:01,550
I'll find a div and on the devil add star to me I said energy four I meant to say Gee if my mistake
29
00:02:03,490 --> 00:02:08,870
will say if the enter text properly is equal to random text then we will show this.
30
00:02:08,900 --> 00:02:10,340
Otherwise we'll hide it.
31
00:02:10,640 --> 00:02:11,970
We'll say random text.
32
00:02:12,110 --> 00:02:15,110
Equal equal equal enter text
33
00:02:19,150 --> 00:02:25,750
while say this and then going to flip back over I'm going to copy that string right there exactly and
34
00:02:25,750 --> 00:02:26,790
throw it into the input.
35
00:02:26,860 --> 00:02:33,800
Mr as I do I see success appear but if I change the entered string then the message goes away by I can
36
00:02:33,800 --> 00:02:38,660
delete and re-enter that last character and every single time I toggle the visibility of the message
37
00:02:38,660 --> 00:02:43,870
at the bottom like I said this is one way to take care of this another way that you might have handle
38
00:02:43,870 --> 00:02:49,990
this is by creating a new property on the class called if you like solved or something and by default
39
00:02:50,020 --> 00:02:56,470
maybe we are not solved mean every single time a user enter some piece of text you could take a look
40
00:02:56,590 --> 00:03:07,740
and compare that value against random text and if they are equal then we can update solved to be true
41
00:03:07,890 --> 00:03:11,200
like so that if you came up with some solution like this.
42
00:03:11,200 --> 00:03:13,690
Like I said this is 100 percent ok as well.
43
00:03:13,900 --> 00:03:17,330
Totally appropriate either solution works just fine.
44
00:03:17,350 --> 00:03:22,630
The only reason that I'm trending towards this initial solution of storing the text value or the entered
45
00:03:22,630 --> 00:03:29,200
text like this is that I know that in just a moment we're going to have to enter or limit access entered
46
00:03:29,200 --> 00:03:34,300
text inside of our template in order to compare all those characters one by one but in my scenario I
47
00:03:34,300 --> 00:03:35,880
just kind of know the future here.
48
00:03:35,880 --> 00:03:40,390
You're having already implemented this thing so if you added in that solve property totally fine.
49
00:03:40,540 --> 00:03:43,200
Either way you're good to go okay.
50
00:03:43,230 --> 00:03:48,820
Now that we've got this put together let's talk about our next step our next step is where things are
51
00:03:48,820 --> 00:03:51,990
going to get a little bit challenging though for our next step.
52
00:03:52,000 --> 00:03:54,970
This is where the real meat and potatoes comes into play.
53
00:03:55,000 --> 00:03:59,890
We want to display every character of our random text inside of the template.
54
00:03:59,890 --> 00:04:04,990
Well we want to color each character depending upon whether it's right wrong or if it hasn't been entered
55
00:04:04,990 --> 00:04:05,850
yet.
56
00:04:05,890 --> 00:04:09,910
Let me give you a couple notes on how to accomplish this because there's definitely many different ways
57
00:04:09,910 --> 00:04:11,420
to solve this.
58
00:04:11,500 --> 00:04:15,950
I'm going to show you one very particular way definitely a lot of different ways of taking care of it.
59
00:04:17,870 --> 00:04:21,830
The first thing I want to mention is that we are not trying to just find the first character that is
60
00:04:21,830 --> 00:04:25,170
wrong and then color everything after it inside red.
61
00:04:25,190 --> 00:04:31,190
Instead we really want to do an exact character by character comparison and we want to color each character
62
00:04:31,430 --> 00:04:36,320
precisely depending upon whether the user has entered the correct character down here inside the text
63
00:04:36,320 --> 00:04:37,340
input.
64
00:04:37,440 --> 00:04:44,030
So in this example we are supposed to enter Lorem if some dealers said Ahmet and then in the text input
65
00:04:44,060 --> 00:04:47,360
we imagine that we entered Lorem everyone those characters is correct.
66
00:04:47,360 --> 00:04:55,550
So they all show up as green then a space and then K.B. some is what was entered the K in the B are
67
00:04:55,550 --> 00:04:56,740
incorrect here.
68
00:04:56,780 --> 00:05:02,660
So up here inside of the randomly generated text we should color just I N P as red because those are
69
00:05:02,660 --> 00:05:09,480
the two characters that were entered incorrectly and then after that we do in fact enter s you m correctly
70
00:05:09,650 --> 00:05:14,390
so in the generated text we should color those as green and everything after that.
71
00:05:14,400 --> 00:05:17,560
We haven't entered any character at s yet so far.
72
00:05:17,670 --> 00:05:21,990
Those should all be just black or gray or something similar again.
73
00:05:21,990 --> 00:05:25,270
We want to make sure that we do a character by character comparison.
74
00:05:25,380 --> 00:05:32,680
Let me give you a couple notes now on how you might approach this there's definitely two over all possibilities
75
00:05:32,770 --> 00:05:34,830
of solving this problem.
76
00:05:35,000 --> 00:05:38,560
The first way that you might solve this is taking a class based approach.
77
00:05:38,570 --> 00:05:43,970
So when I say class based I mean we are going to stuff as much code on the component side or the class
78
00:05:43,970 --> 00:05:49,430
side inside of a method as we can to compare these two strings and then maybe generate some kind of
79
00:05:49,430 --> 00:05:54,340
data structure that describes how our template should actually render out all this data.
80
00:05:54,440 --> 00:06:00,170
So inside this class based approach we might add in a lot of logic too on input right here to take a
81
00:06:00,170 --> 00:06:06,230
look at enter text and take a look at random text and then for every single character generate some
82
00:06:06,230 --> 00:06:12,680
description something somehow to say okay let's show this character in it should be this color that
83
00:06:12,680 --> 00:06:17,720
is the first approach we might take the other approach we might take is to really just take the information
84
00:06:17,720 --> 00:06:22,130
that has been entered by the user and then through a lot of logic into our template to decide how to
85
00:06:22,130 --> 00:06:23,840
show each character.
86
00:06:23,840 --> 00:06:29,600
So in this template based solution what we have already inside of on inputs is like almost enough inside
87
00:06:29,600 --> 00:06:33,440
of your already and we would rely upon a lot of template syntax.
88
00:06:33,500 --> 00:06:38,080
So a lot of stuff that we go through inside of here rely upon rendering out each character and then
89
00:06:38,090 --> 00:06:44,540
coloring each one is readily you and I are going to go with a template based solution.
90
00:06:44,620 --> 00:06:50,590
We're going to rely a lot on making sure that we enter in some template syntax to show each character
91
00:06:50,950 --> 00:06:57,480
and apply some styling or some class to give some styling readily to each individual one which way you
92
00:06:57,480 --> 00:06:58,690
go totally up to you.
93
00:06:58,710 --> 00:07:02,310
Either way really is appropriate here.
94
00:07:02,330 --> 00:07:06,080
Now if you go with the template based solution there is one thing that you're probably going to need
95
00:07:06,080 --> 00:07:14,060
to be aware of chances are you might use say an end G4 to iterate over every entered care or see every
96
00:07:14,060 --> 00:07:19,460
character of random text right here and print out every character as a separate element.
97
00:07:19,460 --> 00:07:23,000
You might use an energy for four that's an N for each character.
98
00:07:23,000 --> 00:07:29,270
You might try to look up the accompanying index inside of enter text so when we discussed energy for
99
00:07:29,270 --> 00:07:34,310
just a little bit ago we just discussed how to use it to iterate through some array of things and print
100
00:07:34,340 --> 00:07:39,650
each one out and we didn't actually discuss how to access the index of every element that we are iterating
101
00:07:39,680 --> 00:07:45,970
over a little hint that I want to give you here is that if you ever need to access the index of an element
102
00:07:46,000 --> 00:07:52,240
as we are iterating over it with energy for you can write out the original or let letter of random text
103
00:07:52,240 --> 00:07:58,750
or whatever else and then a semicolon and then let I equals index and then you will have access to this
104
00:07:58,750 --> 00:08:00,970
variable inside of your template of I.
105
00:08:01,060 --> 00:08:06,960
And that will tell you the exact index that you are working with that they want to mention really quickly.
106
00:08:06,970 --> 00:08:10,920
This is something you might figure out on your own when we're making use of energy for we have to iterate
107
00:08:10,950 --> 00:08:14,280
over an array random text is a string.
108
00:08:14,280 --> 00:08:19,260
And so to turn that string into a array of characters you'd call split on it with an empty string just
109
00:08:19,260 --> 00:08:21,920
one throw that in there really quickly.
110
00:08:21,970 --> 00:08:26,620
Now the other big challenge you're probably going to run into is how to style each individual character.
111
00:08:26,840 --> 00:08:29,440
I'm gonna let you do a little bit of research on that front.
112
00:08:29,470 --> 00:08:31,380
Is that something that you definitely have to figure out.
113
00:08:32,860 --> 00:08:35,860
Again if you're not sure how to tackle any of this don't sweat it.
114
00:08:35,860 --> 00:08:39,000
This really is a very challenging little exercise.
115
00:08:39,000 --> 00:08:43,660
But feel free to pop over to the next video and I'll show you exactly how we would walk through this.
116
00:08:43,660 --> 00:08:48,010
This is definitely it like I said the most challenging aspect of this whole project that you got everything
117
00:08:48,010 --> 00:08:48,920
up to this point.
118
00:08:49,180 --> 00:08:50,980
That is fantastic.
119
00:08:51,030 --> 00:08:54,580
It's let's take a quick pause here and then start to tackle this in just a moment.
13650
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.