diff --git a/components/dropdown.ts b/components/dropdown.ts index fc9768cf08..79bdcc959f 100644 --- a/components/dropdown.ts +++ b/components/dropdown.ts @@ -1,6 +1,8 @@ import {Dropdown} from './dropdown/dropdown.directive'; +import {DropdownMenu} from './dropdown/dropdown-menu.directive'; import {DropdownToggle} from './dropdown/dropdown-toggle.directive'; export {Dropdown} from './dropdown/dropdown.directive'; +export {DropdownMenu} from './dropdown/dropdown-menu.directive'; export {DropdownToggle} from './dropdown/dropdown-toggle.directive'; -export const DROPDOWN_DIRECTIVES: Array = [Dropdown, DropdownToggle]; +export const DROPDOWN_DIRECTIVES: Array = [Dropdown, DropdownToggle, DropdownMenu]; diff --git a/components/dropdown/dropdown-menu.directive.ts b/components/dropdown/dropdown-menu.directive.ts new file mode 100644 index 0000000000..94202ffff3 --- /dev/null +++ b/components/dropdown/dropdown-menu.directive.ts @@ -0,0 +1,16 @@ +import { + Directive, ElementRef, Host, + OnInit +} from 'angular2/core'; + +import {Dropdown} from './dropdown.directive'; + +@Directive({ selector: '[dropdownMenu]' }) +export class DropdownMenu implements OnInit { + constructor( @Host() public dropdown: Dropdown, public el: ElementRef) { + } + + public ngOnInit() { + this.dropdown.dropDownMenu = this; + } +} diff --git a/components/dropdown/dropdown.service.ts b/components/dropdown/dropdown.service.ts index 0d9829215c..63ba07f86f 100644 --- a/components/dropdown/dropdown.service.ts +++ b/components/dropdown/dropdown.service.ts @@ -50,7 +50,7 @@ export class DropdownService { if (event && this.openScope.autoClose === OUTSIDECLICK && this.openScope.menuEl && - this.openScope.menuEl.nativeElement === event.target) { + this.openScope.menuEl.nativeElement.contains(event.target)) { return; }