Тёмный

Angular Dropdown Menu Close On Click Outside 

Monsterlessons Academy
Подписаться 47 тыс.
Просмотров 23 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 94   
@MonsterlessonsAcademy
@MonsterlessonsAcademy Месяц назад
WATCH NEXT: Angular with NgRx - Building Angular Project From Scratch - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vcfZ0EQpYTA.htmlsi=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 Месяц назад
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 Месяц назад
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!
@tuku_mann
@tuku_mann Месяц назад
Thank you so much, Oleksandr! You helped me a lot)
@MonsterlessonsAcademy
@MonsterlessonsAcademy Месяц назад
Glad to hear that!
@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 Месяц назад
Great work. Works perfectly.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Месяц назад
Glad to hear that
@denisvaraksin7686
@denisvaraksin7686 Год назад
Thank you for your tutorial, clean RxJS usage on this one!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You are welcome!
@anasking
@anasking Год назад
thank u so much buddy i was stuck on this for a week
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You are welcome!
@viacheslavpak2394
@viacheslavpak2394 2 года назад
this video is a MUST to watch! thank you
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 года назад
Thank you!
@ChutinunBellTantasathiar
@ChutinunBellTantasathiar Год назад
thank you very much, great video for angular for beginner
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You are welcome!
@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.
@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!
@sumitghewade2002
@sumitghewade2002 Год назад
This video really helped me a lot.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
Glad to hear that!
@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.
@naveenpisher6928
@naveenpisher6928 2 года назад
Very helpfull content, Thank you so much for doing this. Really Appreciated Sir.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 года назад
Glad it was helpful!
@federicobalboa9145
@federicobalboa9145 Год назад
you're the boss! thanks
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You are welcome!
@foo3268
@foo3268 2 года назад
you're saving lives mate
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 года назад
Well, not literally :D
@shanmugakamaleshm4254
@shanmugakamaleshm4254 Год назад
Thanks dude ❤
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
No problem 👍
@SunnyVakil
@SunnyVakil 2 года назад
Helpful video, thank you !
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 года назад
You're welcome!
@SilviuIT-tn3dn
@SilviuIT-tn3dn 11 месяцев назад
are you working on creating and uploading a course in Angular on Udemy?
@MonsterlessonsAcademy
@MonsterlessonsAcademy 11 месяцев назад
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 11 месяцев назад
Thx for reply. I didn't saw it. I just enrolled on it now @@MonsterlessonsAcademy
@SilviuIT-tn3dn
@SilviuIT-tn3dn 11 месяцев назад
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
@pepikkk10
@pepikkk10 Год назад
Thank you SO much!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You're welcome!
@mayronalves7888
@mayronalves7888 2 года назад
TU ME SALVOU DEMAIS, OBRIGADOOOO
@andreifilimonchyk8318
@andreifilimonchyk8318 Год назад
Thanks. the problem is solved!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
Awesome!
@guillermosandoval8416
@guillermosandoval8416 Год назад
Thanks a lot!!!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
You're welcome!
@sridevisridevi3858
@sridevisridevi3858 Год назад
Thank you ✨💫
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
No problem 😊
@SusantaMuduli
@SusantaMuduli Год назад
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 9 месяцев назад
Thanks
@MonsterlessonsAcademy
@MonsterlessonsAcademy 9 месяцев назад
Welcome
@onlydev4099
@onlydev4099 2 года назад
thanks you helped me a lot
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 года назад
Glad I could help!
@drorhandler1316
@drorhandler1316 Год назад
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 Год назад
You have a wrong import. It should come from rxjs not from rxjs/operators
@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
@martin-dw
@martin-dw Год назад
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 Год назад
I found out the problem. It was i wrote capitalazed 'ClickOutside"
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
Awesome!
@studentlearninginformatic4097
wich theme is used for writing code ?
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
It's gruvbox. Here is a video about an editor. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YrLiugDhCuk.html
@PLXris
@PLXris 7 месяцев назад
Unfortunately it does not work for me on Angular 17
@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.
@robertparker3608
@robertparker3608 2 года назад
:thumbs up
@RobG76
@RobG76 Год назад
filter(event) is deprecated
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
Filter is not deprecated. Please use the correct import. rxjs.dev/api/index/function/filter
@PrashantSingh-lb1xh
@PrashantSingh-lb1xh Год назад
Thank you so much, It helped a lot.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Год назад
Glad it helped!
@villemadison
@villemadison 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.
Далее
다리찢기 고인물⁉️😱 Leg Splits Challenge
00:37
Cool Parenting Gadget Against Mosquitos! 🦟👶
00:21
How To Create Advanced CSS Dropdown Menus
16:09
Просмотров 481 тыс.
Customizing Angular Material just got easier in v18!
14:12
What’s new in Angular v18
20:08
Просмотров 128 тыс.
8 TailwindCSS Classes I Wish I Found Earlier
4:48
Просмотров 75 тыс.
Why aren't you using Fastify? Or Koa? Or NestJS?
9:58