在子组件中,我有一个数据表,当我点击该行时,我将获取数据并将其保存在branchToDivision
中,我还有一个按钮,当我点击该按钮时,我可以将branchToDivision
发送到父组件。
儿童组件
@Output() messageEvent: EventEmitter<BranchDto> = new EventEmitter<BranchDto>();
branchToDivision: BranchDto;
onSelect(record: BranchDto) {
this.branchToDivision = new BranchDto();
this.branchToDivision = record;
console.log(this.branchToDivision);
console.log(this.branchToDivision.brancH_CODE);
}
acceptBranch() {
this.onSelect(this.branchToDivision);
this.messageEvent.emit(this.branchToDivision);
this.branchModalDivision.hide();
}
父组件
branch: BranchDto;
getBranch(branch: BranchDto): void{
this.branch = branch;
console.log(this.branch);
console.log(this.branch.brancH_CODE);
}
父HTML
<branchModal #branchModal (messageEvent)="getBranch($event)" ></branchModal>
我尝试记录分支属性,但它是未定义的,有什么问题?任何想法都对我很有帮助。