Angular 如何在HTML属性中编写复杂的Typescript对象

Angular 如何在HTML属性中编写复杂的Typescript对象,angular,Angular,如何编写HTML来填充复杂的@Input参数 如果我有一个像这样的角度分量: @Component({ selector: 'app-one', templateUrl: './one.component.html', styleUrls: ['./one.component.css'] }) export class OneComponent implements OnInit { @Input() data: MyCustomType; ... export class

如何编写HTML来填充复杂的
@Input
参数


如果我有一个像这样的角度分量:

@Component({
  selector: 'app-one',
  templateUrl: './one.component.html',
  styleUrls: ['./one.component.css']
})
export class OneComponent implements OnInit {

  @Input() data: MyCustomType;
...

export class MyCustomType {
  id: string;
  value: number;
}
我可以编写HTML来填充它吗?
类似于:

<app-my data="{'id':'a','value':1}></app-my>

您必须使用如下数据绑定语法:

<app-my [data]="{'id':'a','value':1}"></app-my>

使用此语法时,您可以执行各种javascript操作,例如创建对象、调用方法等。当然,只能使用组件类上可用的内容