我正在使用 Angular 5。其中我使用事件发射器将数据从一个组件传递到另一个组件。
在第一次单击事件发射器不订阅子组件中的值。在第二次点击事件发射器触发两次。
头组件.ts
this.testservice.sendsearchdata.next( this.searchdataform.value)
搜索component.ts
this.testservice.sendsearchdata.subscribe(value=>{
console.log( value)
})
测试服务.ts
public testservice: EventEmitter<any> = new EventEmitter ():
在将响应式表单数据从标题组件传递到搜索组件时,它不会在第一次单击时触发。在下一次单击时,它已触发两次。