【发布时间】:2021-11-15 15:42:19
【问题描述】:
我真的只是想将一些常量传递给 Angular Web 组件。
这是我的 index.html:
<body>
<cast-catalog nVisible="4" [someValue]="'ccccc'"></cast-catalog>
</body>
cast-catalog-component.ts
export class CastCatalogComponent implements OnInit {
@Input('nVisible') numVisible : number = 6;
@Input('someValue') someValue : string ;
<some other code>
对于 numVisible,我仍然得到 6 而不是 4,对于 someValue,我仍然得到一个空白值。如果它将数据从一个组件传递到另一个组件,我没有这个问题,但如果我从 index.html 执行,它就不起作用。
【问题讨论】:
标签: angular input data-binding web-component