countries.json
---------------------
[
{"name" : "India", "code" : "AF"},
{"name" : "Ă…land Islands", "code" : "AX"},
{"name" : "Albania", "code" : "AL"},
{"name" : "Algeria", "code" : "DZ"}
]
app.component.html
-----------------------
<li *ngFor="let country of countryList; index as i; first as isFirst">
{{country.name}} <span *ngIf="isFirst">default</span>
</li>
app.component.ts
---------------------------
import countries from './_files/countries.json';
public countryList:{name:string, code:string}[] = countries;
tsconfig.json
---------------------
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
PostedBy:pankaj_bhakre
No comments:
Post a Comment