在组件的ngOnInit
方法中,@Input
个值将被绑定,因此您可以判断组件上的那些属性,但似乎没有办法判断@Output
个事件绑定.我想知道@Output
是否连接在组件上.
(使用Angular 和字体)
import {Component, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'sample',
template: `<p>a sample</p>`
})
export class SampleComponent {
@Output() cancel = new EventEmitter();
ngOnInit() {
// would like to check and see if cancel was used
// on the element <sample (cancel)="doSomething()"></sample>
// or not <sample></sample>
}
}