Last active
August 29, 2015 14:27
-
-
Save valorkin/ed9fdf26115400043eb8 to your computer and use it in GitHub Desktop.
Is host element event handler is set?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.ts | |
// (close) could be set or not | |
@Component({ | |
selector: 'app' | |
}) | |
@View({ | |
template: ` | |
<alert (close)="closeAlert(i)">{{ alert1.msg }}</alert> | |
<alert>{{ alert2.msg }}</alert> | |
`, | |
directives: [AlertComponent, coreDirectives] | |
}) | |
class Hello{} | |
// alerts.ts | |
@Component({ | |
selector: 'alert', | |
properties: ['type'], | |
events: ['close'], | |
lifecycle: [LifecycleEvent.onInit] | |
}) | |
@View({ | |
template: `...doesn't care`, | |
directives: [coreDirectives, CSSClass] | |
}) | |
class AlertComponent{ | |
constructor(public el: ElementRef){ | |
// TODO: is there a better way to detect that event handler is set? | |
this.closeable = el.nativeElement.getAttribute('(close)'); | |
this.close = new EventEmitter(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vsavkin
yeap, debugged to this point yesterday,
now need to find about an interface of value accessor :)