从EventEmitter响应中检索数据-2个组件Angular之间的通信

时间:2018-08-07 13:51:11

标签: angular eventemitter

我在子Component.ts中有一个EventEmitter

@Output()
 change: EventEmitter<any> = new EventEmitter<any>();
....
FormJson() {
  const myObjStr = JSON.stringify(this.address.value);
 this.change.emit(myObjStr);}

然后在父组件中,调用事件:

AddChange(event) {
this.addr = event;
console.log(this.addr);}

执行后,我在控制台上看到以下结果:

home.component.ts:48 
{"items":[{"street":"df","city":"","state":"","Obligation":""}]}
Event {isTrusted: true, type: "change", target: input.validate.ng-untouched.ng-valid.ng-dirty, currentTarget: app-addresse, eventPhase: 3, …}

我怎么也没有其他信息:

{"items":[{"street":"df","city":"","state":"","Obligation":""}]}

0 个答案:

没有答案