Recently, I delved into the world of Ionic and started working on an app that features a unique 'dictionary' functionality. The app allows users to press a button to hear either an English or German translation of a Dutch word through an audio file. To achieve this, I am utilizing an array within a JSON file named 'Opdracht1.json'. This file contains values mapping translations from Dutch to English/German. Although there are X&Y coordinates for rectangle positions, they are not crucial to the overall functionality. Ultimately, the desired output is to retrieve either an English or German word based on user interaction.
[
{"x": "365", "y": "12", "string": "steiger", "engels": "Jetty", "duits": "Der Steiger"},
{...}
]
Upon navigation from a previous page, I determine the required language ('engels' or 'duits').
// Retrieve language from previous page and assign it to 'taal'
this.taal = navParams.get('taal');
console.log(this.taal);
The current approach involves implementing a for loop for clickable rectangles within an SVG element to play corresponding 'audio' files. In the click function, I am attempting to accurately identify the language associated with the clicked item.
<svg viewBox="0 0 1280 720" *ngIf="id === 'SamenwerkenOpDeCorridor'">
<image width="1280" height="720" xlink:href="assets/imgs/maps/SamenwerkenOpDeCorridor/opdracht1.svg">
</image>
<rect *ngFor="let item of coordinaten" [attr.x]="item.x" [attr.y]="item.y" width="200" height="45" fill="#fff" opacity="0" (click)="clickOnArea(item.taal)"
/>
</svg>
Hence, obtaining the correct language in the click function is imperative. While coding it directly as "clickOnArea(item.engels)" proves functional, the aim is to make this process more dynamic.