Javascript 将元素与Spring中的多个关系关联+;有棱角的

Javascript 将元素与Spring中的多个关系关联+;有棱角的,javascript,html,arrays,angular,typescript,Javascript,Html,Arrays,Angular,Typescript,在我的项目中,我有两个类具有CodeA和CodeB之间的manytomy关系。 在这种情况下: CodeA.java CodeB.java 然后在DB中,我输入了以下数据: code_a ----------- | id | code | ----------- | 1 | A1 | ----------- | 2 | A2 | ----------- | 3 | A3 | ----------- code_b ----------- | id | cod

在我的项目中,我有两个类具有
CodeA
CodeB
之间的
manytomy
关系。 在这种情况下:

  • CodeA.java
  • CodeB.java
然后在DB中,我输入了以下数据:

code_a
 -----------
| id | code |
 -----------
| 1  |  A1  |
 -----------
| 2  |  A2  |
 -----------
| 3  |  A3  |
 -----------

code_b
 -----------
| id | code |
 -----------
| 1  |  a1  |
 -----------
| 2  |  a2  |
 -----------
| 3  |  a3  |
 -----------
| 4  |  a4  |
 -----------

code_a_associated_code
 --------------------------------
| code_a_id | associated_code_id |
 --------------------------------
| 1         |  1                 |
 --------------------------------
| 1         |  2                 |
 --------------------------------
| 2         |  1                 |
 --------------------------------
| 2         |  2                 |
 --------------------------------
| 2         |  3                 |
 --------------------------------
| 2         |  4                 |
 --------------------------------
| 3         |  1                 |
 --------------------------------

在前端,有相关的类:

  • CodeA.ts
  • CodeB.ts
我如何在我的摘要页面中进行管理,根据我拥有的代码,选择代码在选项中的位置?我试过了,但没用

  • summary.ts
  • summary.html
{{c.code}
{{a.code}}

您能澄清一下您的问题吗?你想做什么,什么不起作用?@YogendraR,数据没有输入选择。如果有A1代码,select中的选项为空。我想您必须调试/告诉我们更多信息。后端是否返回任何内容,getCodeB()中是否分配了属性。订阅?使用console.log()。因为您需要A和B,所以通常使用forkJoin。您的实体似乎是错误的,因为很多实体都需要一个列表(或集合)。我有一种感觉,最好在前端也有一个B数组作为a的一部分
@Entity
@Table(name = "codeB")
public class CodeB {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column
    private String code;

    //BELOW GET AND SET...
}
code_a
 -----------
| id | code |
 -----------
| 1  |  A1  |
 -----------
| 2  |  A2  |
 -----------
| 3  |  A3  |
 -----------

code_b
 -----------
| id | code |
 -----------
| 1  |  a1  |
 -----------
| 2  |  a2  |
 -----------
| 3  |  a3  |
 -----------
| 4  |  a4  |
 -----------

code_a_associated_code
 --------------------------------
| code_a_id | associated_code_id |
 --------------------------------
| 1         |  1                 |
 --------------------------------
| 1         |  2                 |
 --------------------------------
| 2         |  1                 |
 --------------------------------
| 2         |  2                 |
 --------------------------------
| 2         |  3                 |
 --------------------------------
| 2         |  4                 |
 --------------------------------
| 3         |  1                 |
 --------------------------------

export class CodeA {
  id: number
  code: string
}
export class CodeB {
  id: number
  code: string
}
    codeA: CodeA[]
    codeB: CodeB[]
    
    this.service.getCodeA().subscribe(data => {
       this.codeA = data;
    })
    this.service.getCodeB().subscribe(data => {
       this.codeB = data;
    })