{"action":"opened","issue":{"url":"https://api.github.com/repos/primefaces/primeng/issues/857","repository_url":"https://api.github.com/repos/primefaces/primeng","labels_url":"https://api.github.com/repos/primefaces/primeng/issues/857/labels{/name}","comments_url":"https://api.github.com/repos/primefaces/primeng/issues/857/comments","events_url":"https://api.github.com/repos/primefaces/primeng/issues/857/events","html_url":"https://github.com/primefaces/primeng/issues/857","id":175119018,"number":857,"title":"Menubar event emmiter broken after hide and show","user":{"login":"SethiaKynes","id":9725428,"avatar_url":"https://avatars.githubusercontent.com/u/9725428?v=3","gravatar_id":"","url":"https://api.github.com/users/SethiaKynes","html_url":"https://github.com/SethiaKynes","followers_url":"https://api.github.com/users/SethiaKynes/followers","following_url":"https://api.github.com/users/SethiaKynes/following{/other_user}","gists_url":"https://api.github.com/users/SethiaKynes/gists{/gist_id}","starred_url":"https://api.github.com/users/SethiaKynes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SethiaKynes/subscriptions","organizations_url":"https://api.github.com/users/SethiaKynes/orgs","repos_url":"https://api.github.com/users/SethiaKynes/repos","events_url":"https://api.github.com/users/SethiaKynes/events{/privacy}","received_events_url":"https://api.github.com/users/SethiaKynes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-05T19:21:20Z","updated_at":"2016-09-05T19:21:20Z","closed_at":null,"body":"Hi,\r\n\r\nI use Menubar component wrapped in a div with ngIf:\r\n```\r\n<div *ngIf=\"authService.isLoggedIn()\">\r\n    <p-menubar [model]=\"nestedItems\"></p-menubar>\r\n</div>\r\n```\r\n\r\nOn one of the items have a command set.\r\n```\r\nthis.nestedItems = [\r\n\t\t\t{\r\n\t\t\t\tlabel: 'Logout',\r\n\t\t\t\ticon: 'fa-sign-out',\r\n                command: (event) => {this.logout(event)}\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tlabel: 'Home',\r\n                icon: 'fa-home',\r\n\t\t\t\trouterLink: ['/home']\r\n\t\t\t}\r\n\t\t];\r\n```\r\n\r\nWhen I show the component for the first time everything works fine and command is called as expected. After the component is hidden and then showed again, when I click 'Logout' item I get the error \"ObjectUnsubscribedError\". Source of the error is call: \"item.eventEmitter.emit(event);\" from MenubarSub class.\r\n\r\nIt works fine after setting eventEmmiter anew with each call, but I'm not sure if that's the optimal solution. Maybe I'm using it wrong?\r\n```\r\nitemClick(event, item: MenuItem) {\r\n        if(!item.url||item.routerLink) {\r\n            event.preventDefault();\r\n        }\r\n        \r\n        if(item.command) {\r\n            if(!item.eventEmitter) {\r\n                item.eventEmitter = new EventEmitter();\r\n                item.eventEmitter.subscribe(item.command);\r\n            } else {\r\n                item.eventEmitter.unsubscribe();\r\n                item.eventEmitter = new EventEmitter();\r\n                item.eventEmitter.subscribe(item.command);\r\n            }\r\n            \r\n            item.eventEmitter.emit({\r\n                originalEvent: event,\r\n                item: item\r\n            });\r\n        }\r\n\r\n        if(item.routerLink) {\r\n            this.router.navigate(item.routerLink);\r\n        }\r\n        \r\n        this.activeItem = null;\r\n        this.activeLink = null;\r\n    }\r\n```"}}
{"actor":{"display_login":"SethiaKynes"}}