【发布时间】:2021-10-31 06:23:20
【问题描述】:
我需要将我的子组件中的一个变量传递给父页面。 我试图传递的这个变量,是 Barcode Scanner 的数组结果。
我需要将它传递给父级以发送到 API。
childComponent.ts
this.consultList;
parentComponent.ts
export class ParentComponent implements OnInit {
@Input() consultList: any[] = [];
testCall() {
console.log('Test Consult: ', this.consultList;
}
【问题讨论】:
-
你可以使用
@Input()和@Output()事件来传递变量,从父到子你可以使用@Input()在子组件中定义的变量,从子到父你可以使用事件绑定在子组件中定义@Output。 -
您好,如果我的回答解决了您的问题,请标记为回答
标签: javascript angularjs typescript ionic-framework