从资产文件夹导入文件(自己的 .ext)
Import file from assets folder (own .ext)
我的资产文件夹中有一个名为 data.myext
的文件
如您所见,扩展名是自定义的。
里面的数据是这样的:
mydata = [
{
"name": “SOMENAME”,
‘value’: : 01345
}
]
我想将其导入我的 app.component.ts / html
并像这样阅读:
例如:
{{ mydata.name }} or from the .ts file using ... `mydata.name`
如何做到这一点?
mydata 不是数组。您可以像这样渲染对象。
App.component.html
mydata[0].name
循环示例
<div *ngFor="let item of mydata">
<span>{{ item.name }}</span>
</div>
我的资产文件夹中有一个名为 data.myext
的文件如您所见,扩展名是自定义的。
里面的数据是这样的:
mydata = [
{
"name": “SOMENAME”,
‘value’: : 01345
}
]
我想将其导入我的 app.component.ts / html
并像这样阅读:
例如:
{{ mydata.name }} or from the .ts file using ... `mydata.name`
如何做到这一点?
mydata 不是数组。您可以像这样渲染对象。
App.component.html
mydata[0].name
循环示例
<div *ngFor="let item of mydata">
<span>{{ item.name }}</span>
</div>