39_enhancing_nglf_with_an_else_condition

Jul 13, 2026 07:20 · 2:46 · English · Whisper Turbo · 1 اسپيڪر
هيءَ ترانسڪريٽ اڄ ختم ٿيندي. ساري وقت جي ذخيري لاءِ اپ گريڊ →
صرف ڏيکارڻ
0:02
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
In the last lecture we had a look at the basic ngif syntax and
0:06
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
that's the syntax you're going to use most of the time.
0:08
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
There is one alternative to it though.
0:11
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Sometimes you have not only the if condition but also
0:15
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
an else condition.
0:16
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So here we might want to say server was created server name is
0:20
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
something with ngif but we could also add an else block
0:24
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
where we then want to say no server was created.
0:27
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Now, we deleted that exact text for the reason that we don't want to see it,
0:31
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
but imagine that we do want to show that alternative.
0:34
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So, no server was created,
0:37
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
could be the text here,
0:38
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
and now we want to show this paragraph only if ngif is not true,
0:42
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
or this condition,
0:43
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
server created,
0:44
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
is not true.
0:46
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
We can achieve this by placing a local reference
0:50
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
on this element here.
0:52
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And local reference is something I will dive deeper into in
0:57
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
the understanding components and data binding section of this course.
1:00
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
For now,
1:00
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
let's think of it as a marker.
1:02
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So I will name this no server,
1:05
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
any name you like.
1:07
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Let's name this no server with a capital S.
1:09
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And now we need to change the paragraph here to
1:14
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
ng -template.
1:15
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
That is a component,
1:17
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
a directive shipping with Angular,
1:19
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
which you can use to mark places in the DOM.
1:23
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And now I will add the paragraph back in this template with
1:28
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
the text in between like this.
1:29
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So now basically the text you want to output.
1:32
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And now with ng -template with the local references marker on
1:36
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
it, we mark a certain spot in the template,
1:39
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
which we want to show conditionally.
1:42
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Now to show it conditionally,
1:44
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
we simply enhance ngif by also adding else and
1:48
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
then no server.
1:50
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So this marker replaced on ng -template.
1:52
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And that's all the syntax we need.
1:55
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
If we save this,
1:56
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
you see no server was created.
1:58
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And as soon as I click here,
2:00
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
that gets replaced with server was created.
2:02
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
So that is ngif else.
2:04
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
A nice little addition in a use case where you have,
2:07
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
well, an else condition.
2:10
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Of course, the alternative would always be to simply use ngif with
2:14
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
the reversed check,
2:15
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
so with exclamation mark server created.
2:18
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
But that here is another nice alternative.
2:21
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Now,
2:21
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
I'm going to delete it.
2:23
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
You will find an article after the section here,
2:26
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
though, where you can find this code again in case you're interested.
2:29
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
And we will also use this code in the course project we're going
2:34
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
to build.
2:34
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
I just wanted to highlight that this option exists.
2:38
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Using NGF like this,
2:39
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
however, is the case you will see most often.
2:42
S… Speaker 1 (39_enhancing_nglf_with_an_else_condition)
Now let's continue.

هيءَ ترانسڪريٽ AI (آٽوميٽڪ سڏ سڃاڻپ) پاران تيار ڪئي وئي آھي. ان ۾ غلطيون ٿي سگھن ٿيون - اصل آڊيو سان چيڪ ڪريو ته جيئن خطرناڪ استعمال ڪري سگھجي. AI پاليسي

❤️ STT.ai کي پيارو آهي؟ پنھنجن دوستن کي چئو!
خلاصو
ھن ترانسڪريپٽ جي AI خلاصي پيدا ڪرڻ لاءِ خلاصو دٻايو.
خلاصو ڪيو وڃي ٿو...
AI کان ان ترانسڪريپٽ بابت پڇو
ھن ترانسڪريپشن بابت ڪابه سوال ڪريو - AI لاڳاپيل حصا ڳوليندو ۽ جواب ڏيندو.