In my current Angular 8 project I have two JSON files which should be connected to one JSON array. The new file should then be exported.
After googling for a long time I didn't find a solution how to use the two JSON files, which I call up via two HTML inputs, so that I can combine both files in the Angular Component to form a JSON array with input from both JSON files.
My current code:
JsonConverterComponent.html
<div class="form-group">
<label for="Json1">Json 1</label>
<input [(ngModel)]="json1" type="file" id="Json1" required>
</div>
<div class="form-group">
<label for="Json2">Json 2</label>
<input [(ngModel)]="json2" type="file" id="Json2" required>
</div>
<button [buttonLabel]="buttonNameJson" [disableCheck]="!json1 || !json2" (click)="combineJSON()"></button>
JsonConverterComponent.TS
export class JsonConverterComponent implements OnInit {
constructor(private http: HttpClient) { }
ngOnInit() {
}
buttonNameJson = "Combine JSON";
json1: File;
json2: File;
test: File;
one = this.json1;
two = this.json2;
public combineJSON() {
this.test = this.one;
console.log(this.test);
}
}
If I just want to call up the content of one of the two imported JSON files, I always get the error "undefined".
What do I have to do so that I can use the individual JSON in JsonConverterComponent.ts?