I have a file in my assets folder called data.myext
As you can see the extension is custom.
The data inside looks like this:
mydata = [
{
"name": “SOMENAME”,
‘value’: : 01345
}
]
I want to import this to my app.component.ts / html
and read it like this:
For example:
{{ mydata.name }} or from the .ts file using ... `mydata.name`
How can this be done?
CodePudding user response:
mydata is not Array. You can render object like this.
App.component.html
mydata[0].name
Loop example
<div *ngFor="let item of mydata">
<span>{{ item.name }}</span>
</div>
Remember if you change on app.component, you have to restart @cli