我正在使用以下组件:https://github.com/dougludlow/ng2-bs3-modal ,它有一个 onClose()
输出事件。
当 onClose()
被触发时,我想在其父组件上执行一些操作。这是我目前所得到的,但它不起作用(并且也没有错误):
import { MODAL_DIRECTIVES, ModalComponent } from 'ng2-bs3-modal/ng2-bs3-modal';
@Component({
selector: 'dash-data-entry',
template: '<modal (onClose)="reset()" #modal [size]="lg"></modal>',
directives: [MODAL_DIRECTIVES, ModalComponent],
})
export class DashDataEntry {
reset(){
console.log('modal closed');
}
}
关闭模式时,当前不会触发 reset()
事件 - 我做错了什么?
谢谢!
最佳答案
您可以从 Angular2 文档中了解亲子交互:https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#child-to-parent .
关于javascript - 将子组件的输出发送到父组件 - Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38258355/