Java 角度+;中关联类的链接值;春季项目
在我的Spring+Angular项目中,我必须插入一个摘要页面。在上一页(codeChoice.ts)中,用户可以选择一个Java 角度+;中关联类的链接值;春季项目,java,arrays,angular,typescript,spring-boot,Java,Arrays,Angular,Typescript,Spring Boot,在我的Spring+Angular项目中,我必须插入一个摘要页面。在上一页(codeChoice.ts)中,用户可以选择一个code。此代码的值在摘要页面上用于执行计算 代码选择 在摘要页面中,我必须将代码的价格添加到相关的代码中,然后应用附件的百分比和字母参数。这就是为什么我想到在后端创建一个关联类来管理两个类之间的联合: AssociationSummary.java 在前端,相应地: association-summary.ts 其中CodeA和CodeB具有此变量:
code
。此代码的值在摘要页面上用于执行计算
- 代码选择
- AssociationSummary.java
- association-summary.ts
export class CodeA {
id: number
codeA: string
priceA: number
}
export class CodeB {
id: number
codeB: string
priceB: number
}
因此,有了这些数据,我如何将用户在上一页中选择的代码以及由CodeA
带来的代码链接到关联的类AssociationSummary
?
在summary.ts
页面中,我已经完成了以下工作:
export class Summary implements OnInit {
constructor(
private service: AssociationSummaryService
) { }
code: CodeA[]
association: AssociationSummary[]
ngOnInit() {
//I load the service data from the db
this.service.getAssociationSummary().subscribe(data => {
this.association = data;
})
// the code taken from the previous page
this.code = window.history.state.code
}
}
以下是摘要页面的外观示例:
export class AssociationSummary {
id: number
codeA: CodeA
codeB: CodeB
percentage: number
accessories: string
}
export class CodeA {
id: number
codeA: string
priceA: number
}
export class CodeB {
id: number
codeB: string
priceB: number
}
export class Summary implements OnInit {
constructor(
private service: AssociationSummaryService
) { }
code: CodeA[]
association: AssociationSummary[]
ngOnInit() {
//I load the service data from the db
this.service.getAssociationSummary().subscribe(data => {
this.association = data;
})
// the code taken from the previous page
this.code = window.history.state.code
}
}