Angular Dropdown Menu Close On Click Outside

  Рет қаралды 23,975

Monsterlessons Academy

Monsterlessons Academy

Күн бұрын

Пікірлер: 97
@MonsterlessonsAcademy
@MonsterlessonsAcademy 4 ай бұрын
WATCH NEXT: Angular with NgRx - Building Angular Project From Scratch - kzbin.info/www/bejne/rJTJi2N7htWMiqMsi=BptT7eqgflHIoQiQ
@kurtkhalidisrael1510
@kurtkhalidisrael1510 2 жыл бұрын
Thank you very much, I'm a beginner with angular and this helped with my particular use case in my own project! I wish there were more content like this with angular that's freely available.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Glad it helped!
@amarjitaliaskaransharma7724
@amarjitaliaskaransharma7724 4 ай бұрын
thank u, I was stuck in these problem upto 2weeks also my senior didn't solved my problems. I hope u making more content like that. Again, Thanks
@MonsterlessonsAcademy
@MonsterlessonsAcademy 4 ай бұрын
Glad it helped!
@sergeypugach6687
@sergeypugach6687 2 жыл бұрын
Great video, it would be nice to have more content like this with Angular
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Thank you!
@luczztem
@luczztem Жыл бұрын
and again you are my hero! thank you so much bro after 2 days searching for anything that worked for what I needed, this was the only solution! thanks a lot!!!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@danielmathers2483
@danielmathers2483 4 ай бұрын
Great work. Works perfectly.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 4 ай бұрын
Glad to hear that
@tuku_mann
@tuku_mann 4 ай бұрын
Thank you so much, Oleksandr! You helped me a lot)
@MonsterlessonsAcademy
@MonsterlessonsAcademy 4 ай бұрын
Glad to hear that!
@denisvaraksin7686
@denisvaraksin7686 2 жыл бұрын
Thank you for your tutorial, clean RxJS usage on this one!
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
You are welcome!
@anasking
@anasking Жыл бұрын
thank u so much buddy i was stuck on this for a week
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@ChutinunBellTantasathiar
@ChutinunBellTantasathiar Жыл бұрын
thank you very much, great video for angular for beginner
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@viacheslavpak2394
@viacheslavpak2394 2 жыл бұрын
this video is a MUST to watch! thank you
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Thank you!
@egonknapen4079
@egonknapen4079 2 жыл бұрын
I like your version with fromEvent. The biggest problem I do however have, with this idea, is that if you have, say like 100 elements with clickoutside directives on your page, all those 100 elements will be triggered when you click somewhere. So shouldn't you somehow, disable that subscription and only check, when the menu is opened?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
That's a valid point. If you know in advance that you have 100 elements I would register 1 listener on body and do checks and not register it in every element.
@nosbookstv9326
@nosbookstv9326 2 жыл бұрын
Thanks for that comment, did not think about that before reading your comment, i subscribe only when its open and unsubscribe when close menu or when its destroy and removed afterviewinit. In that way there are no subscription if menu are closed
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
@@nosbookstv9326 Sure you can also do that. Depends on your usecase.
@sumitghewade2002
@sumitghewade2002 2 жыл бұрын
This video really helped me a lot.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Glad to hear that!
@maneshipocrates
@maneshipocrates 4 күн бұрын
Thanks. Can someone use this in a navbar with mutiple dropdown menus in TailwindCSS/Angular? Are there any overhead associated with that?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 4 күн бұрын
No if you unsubscribe
@maneshipocrates
@maneshipocrates 4 күн бұрын
@@MonsterlessonsAcademy Thanks again. I will see how I can use it. But if you unsubscribe, will it take care of unsubscribing the subscription? Especially if I also want any drop down menu to close if I click outside too.
@naveenpisher6928
@naveenpisher6928 2 жыл бұрын
Very helpfull content, Thank you so much for doing this. Really Appreciated Sir.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Glad it was helpful!
@foo3268
@foo3268 2 жыл бұрын
you're saving lives mate
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Well, not literally :D
@automobilitv
@automobilitv Жыл бұрын
Thank you very much for this tutorial.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@raphaelrodriguescoelho9375
@raphaelrodriguescoelho9375 2 жыл бұрын
Thanks very much for this video! That really help me today at work :)
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Great to hear!
@mayronalves7888
@mayronalves7888 2 жыл бұрын
TU ME SALVOU DEMAIS, OBRIGADOOOO
@shanmugakamaleshm4254
@shanmugakamaleshm4254 Жыл бұрын
Thanks dude ❤
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
No problem 👍
@federicobalboa9145
@federicobalboa9145 Жыл бұрын
you're the boss! thanks
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You are welcome!
@sridevisridevi3858
@sridevisridevi3858 Жыл бұрын
Thank you ✨💫
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
No problem 😊
@pepikkk10
@pepikkk10 Жыл бұрын
Thank you SO much!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You're welcome!
@SunnyVakil
@SunnyVakil 2 жыл бұрын
Helpful video, thank you !
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
You're welcome!
@onlydev4099
@onlydev4099 2 жыл бұрын
thanks you helped me a lot
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Glad I could help!
@guillermosandoval8416
@guillermosandoval8416 Жыл бұрын
Thanks a lot!!!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
You're welcome!
@SusantaMuduli
@SusantaMuduli 2 жыл бұрын
Sir, if I used same drop-down in more than two times means I want more drop down in same page then this outside click directive is not working
@VinayKrishna-l7z
@VinayKrishna-l7z Жыл бұрын
Thanks
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Welcome
@andreifilimonchyk8318
@andreifilimonchyk8318 2 жыл бұрын
Thanks. the problem is solved!
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Awesome!
@SilviuIT-tn3dn
@SilviuIT-tn3dn Жыл бұрын
are you working on creating and uploading a course in Angular on Udemy?
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
No because my Angular course is updated and is already there on Udemy www.udemy.com/course/angular-and-ngrx-building-real-project-from-scratch/
@SilviuIT-tn3dn
@SilviuIT-tn3dn Жыл бұрын
Thx for reply. I didn't saw it. I just enrolled on it now @@MonsterlessonsAcademy
@SilviuIT-tn3dn
@SilviuIT-tn3dn Жыл бұрын
i also don't understand why Udemy is so dumb. I found your username, i was expecting when i click your profile to see all your courses posted, but i only see a description...@@MonsterlessonsAcademy
@SuperHaubi
@SuperHaubi 2 жыл бұрын
great video, thanks a lot -- i'd also have one question: within the dropdown i have some buttons with click events like
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
You need to use stopPropagation to prevent bubbling an event.
@studentlearninginformatic4097
@studentlearninginformatic4097 2 жыл бұрын
wich theme is used for writing code ?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
It's gruvbox. Here is a video about an editor. kzbin.info/www/bejne/j6Ovmqidec12q80
@PrashantSingh-lb1xh
@PrashantSingh-lb1xh 2 жыл бұрын
Thank you so much, It helped a lot.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Glad it helped!
@drorhandler1316
@drorhandler1316 2 жыл бұрын
First thank you for the video, i'm getting deprecated on the event that the method filter is getting, how can i fix it?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
You have a wrong import. It should come from rxjs not from rxjs/operators
@gabriel_reguera
@gabriel_reguera Жыл бұрын
What to do when I use a dropdown with position absolute? it does not work
@gabriel_reguera
@gabriel_reguera Жыл бұрын
forget it, I was using pointer-events: none, that's why it didn't work 😅
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Glad you fixed that!
@alaakhalila9022
@alaakhalila9022 2 жыл бұрын
What about host listener?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Host listener is an imperative example of doing things which doesn't fit good in Angular RxJS concepts. I recommend to do everything in streams/rxjs way as then it is easier to combine and apply different logic.
@martin-dw
@martin-dw 2 жыл бұрын
I have problem. I try this but is not working, the styles are in the global CSS, the directive is on the app folder and the directive is the same of yours but it doesnt work. I dont know exactly why this isn't working, can you please give me some advice or a clue that what could be the problem?
@martin-dw
@martin-dw 2 жыл бұрын
I found out the problem. It was i wrote capitalazed 'ClickOutside"
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Awesome!
@TechAdiViews
@TechAdiViews 2 жыл бұрын
nice video, one doubt I have, what if we have multiple main menu, then if you click any menu all are showing simultaneously. can you plz send me the code?
@sudhakargajja4496
@sudhakargajja4496 2 жыл бұрын
For me also same doubt sir Can you please help
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
If you have several menus you need several isOpened states then for every menu.
@TechAdiViews
@TechAdiViews 2 жыл бұрын
@@MonsterlessonsAcademy yes right but I want dynamically state will change, like when i click on one menu then previous menu state will remove and add it to current mene?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
@@TechAdiViews you set 1 property to false and other to true.
@sudhakargajja4496
@sudhakargajja4496 2 жыл бұрын
Hello sir Can you please give code or explanation for ngx-owl-carousal
@PLXris
@PLXris 10 ай бұрын
Unfortunately it does not work for me on Angular 17
@RobG76
@RobG76 Жыл бұрын
filter(event) is deprecated
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Filter is not deprecated. Please use the correct import. rxjs.dev/api/index/function/filter
@robertparker3608
@robertparker3608 2 жыл бұрын
:thumbs up
@vilzor
@vilzor 2 жыл бұрын
Doing that manual unsubscription seems heavy to me. I would make a BaseComponent that implements OnDestroy having a var of smth ngUnsubscribe: Subject. In that BaseComponent ngOnDestroy function write 2 lines: this.ngUnsubscribe.next() and this.ngUnsubscribe.complete(). Now when developing components extend that BaseComponent and each subscription that needs to be destroyed have a pipe of ...pipe(takeUntil(this.ngUnsubscribe)). Now all of your subscriptions are killed when your component get's destroyed. No more headache of memory leak via subscriptions :)
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
This is exactlly what I do in real projects but I don't want to make tutorials more complicated with additional things.
@jaysizmir9432
@jaysizmir9432 2 жыл бұрын
@@MonsterlessonsAcademy Personnally i prefer real projects things. Even if it seems complicated i don't mind !
@egonknapen4079
@egonknapen4079 2 жыл бұрын
It can be done even much simpler: subs: Subscription = new Subscription(); subs.add(.....subscribe(....); subs.add(.....subscribe(....); subs.add(.....subscribe(....); subs.add(.....subscribe(....); and now just call this.subs.unsubscribe(); in your base class ngOnDestroy() and all 4 are unsubscribed..
@sudhakargajja4496
@sudhakargajja4496 2 жыл бұрын
For me it's showing error at this.documentClickSubscription?. unsubscribe (); Showing that expected ":" at above line in my project
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
You can take a source code from the description and compare with yours to find a typo.
@sudhakargajja4496
@sudhakargajja4496 2 жыл бұрын
@@MonsterlessonsAcademy actually I have used that only previously
@MrShevrin
@MrShevrin 2 жыл бұрын
greatable thanx for your channel! remark - this way doesn't work for elemnts if their parent have ViewEncapsulation.ShadowDom
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 жыл бұрын
Thanks for the info! I never used that before.
Top 5 Angular Mistakes - You Must Know Them
10:32
Monsterlessons Academy
Рет қаралды 61 М.
Change Detection in Angular - You Project Is 20x Slower!
15:16
Monsterlessons Academy
Рет қаралды 74 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
8 Rules For Learning to Code in 2025...and should you?
12:59
Travis Media
Рет қаралды 189 М.
Animated Dropdown Menu - React + TailwindCSS Tutorial for Beginners
24:50
Build Angular Modal Without Libs - Angular Dynamic Component
16:22
Monsterlessons Academy
Рет қаралды 18 М.
Angular Authentication and Authorization - The Correct Way
23:30
Monsterlessons Academy
Рет қаралды 37 М.
Are we going back to PHP with fullstack JavaScript?
9:57
Maximilian Schwarzmüller
Рет қаралды 160 М.
ngTemplateOutlet is WAY more useful than I realised
16:36
Joshua Morony
Рет қаралды 78 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 445 М.
Service Workers: Why Aren’t More Developers Using This Hidden Gem?
16:14
Monsterlessons Academy
Рет қаралды 2 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН