0

Angular2 Close dropdown on click outside, is there an easiest way?

I did try the code mentioned in above link but it seems .contains function is always returning false.

My control

<multiselect-dropdown>
<button>Click</button>
<a href=""> Click here</a>
</multiselect-dropdown>

User can click either on the button or link inside multi select. If they can click on button or a href i want mouse event target to return true and when clicked on body of the page (not on control) then return false. It seems elementref.nativeelement.contains always returns false when clicked on child component of multiselect.

Community
  • 1
  • 1
Robin Kedia
  • 283
  • 3
  • 16

1 Answers1

0

Your <button> element has an redundant <

<button><</button>

should be

<button></button>
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567