Issue
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?
Solution
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>
Answered By - Batbayr Batmunkh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.