Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

exclude don't work #44

Open
veronesecoms opened this issue Sep 13, 2018 · 3 comments
Open

exclude don't work #44

veronesecoms opened this issue Sep 13, 2018 · 3 comments

Comments

@veronesecoms
Copy link

I have one element (#informacao) that i don't need to fire the clickout event.

This is my code:

    <div [exclude]="'#informacao'" (clickOutside)="teste()" id="cardnotificacao" *ngIf="mostraNotificacoes" class="card cardnotificacoes animated zoomIn">
        <div *ngIf="temNotificacao" class="block-success"><i class="fa fa-clock-o mr-2 iconclock"></i>14:35: Seu plano foi renovado! Obrigado por utilizar o sistema. :) <i (click)="limpaNotificacao()" id="informacao" class="fa fa-close fecharnotificacao ml-2"></i></div>
        <div *ngIf="!temNotificacao" class="block-success animated fadeIn"><i class="fa fa-thumbs-o-up mr-2 iconclock"></i>Você não possui novas notificações!</div>
    </div>

I also try:

<div [exclude]="'.fa'" (clickOutside)="teste()"

and:

<div [exclude]="'.fa,.fa-close,.fecharnotificacao,.ml-2'"

But the event is triggered when i click in my i element

@dbrody
Copy link

dbrody commented Jul 11, 2019

@veronesecoms ng-click-outside seems to cache the DOM nodes that are excluded by default. It seems like there may be more efficient ways of doing this exclude check but I'll ignore that for now.

To fix this, try setting:

<... [excludeBeforeClick]="true" ...>

This will be sure to recreate the exclude list after each click ensuring that created elements (such as your element by the ngIf) is registered.

Hope that helps!

@saeed-abdul-rahim
Copy link

saeed-abdul-rahim commented Nov 5, 2020

[excludeBeforeClick]="true" didn't help
I am having a modal with ng-select
where if I click the dropdown - it is considered as an outside click

@ghost
Copy link

ghost commented Aug 4, 2021

In click outside event you can check the event target and can handle the closing functionality of the modal with it! It worked for me.
For example:

if (!(event.target as HTMLElement).classList.contains('ng-option')) {
     this.closeProductsList();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants