Hello everyone,
Here is the structure of my table :
https://i.sstatic.net/rTbiC.png
The code for the table is as follows:
<tr ng-repeat="item in captions | filter:search:strict">
<td>{{item.CodeId}}</td>
<td>{{item.EnumCaption}}</td>
<td>
<p ng-repeat="language in item.languages"
ng-if="language.CodeLanguage=='nl' && language.CodeCountry=='BE'">
<a href="#"
onaftersave="updateCaption(language)"
editable-textarea="language.Caption"
e-cols="25"
e-rows="{{(language.Caption.length/25)+3}}">{{language.Caption}}</a>
</p>
</td>
<td>
<p ng-repeat="language in item.languages"
ng-if="language.CodeLanguage=='en' && language.CodeCountry=='GB'">
<a href="#"
onaftersave="updateCaption(language)"
editable-textarea="language.Caption"
e-cols="25"
e-rows="{{(language.Caption.length/25)+3}}">{{language.Caption}}</a>
</p>
</td>
<td>
<p ng-repeat="language in item.languages"
ng-if="language.CodeLanguage=='fr' && language.CodeCountry=='BE'">
<a href="#"
onaftersave="updateCaption(language)"
editable-textarea="language.Caption"
e-cols="25"
e-rows="{{(language.Caption.length/25)+3}}">{{language.Caption}}</a>
</p>
</td>
<td>
<p ng-repeat="language in item.languages"
ng-if="language.CodeLanguage=='de' && language.CodeCountry=='DE'">
<a href="#"
onaftersave="updateCaption(language)"
editable-textarea="language.Caption"
e-cols="25"
e-rows="{{(language.Caption.length/25)+3}}">{{language.Caption}}</a>
</p>
</td>
</tr>
The JSON data is as follows:
Captions =
[
{
CodeId: 1,EnglishCaption: "",EnumCaption: "",
languages:
[
{Caption: "",CodeCountry: "DE",CodeId: 1,CodeLanguage: "de",EnumCaption: ""},
{Caption: "",CodeCountry: "GB",CodeId: 1,CodeLanguage: "en",EnumCaption: ""},
{Caption: "",CodeCountry: "BE",CodeId: 1,CodeLanguage: "fr",EnumCaption: ""},
{Caption: "",CodeCountry: "BE",CodeId: 1,CodeLanguage: "nl",EnumCaption: ""}
]
}
,
{
CodeId: 2,EnglishCaption: "",EnumCaption: "",
languages:
[
{Caption: "",CodeCountry: "DE",CodeId: 2,CodeLanguage: "de",EnumCaption: ""},
{Caption: "",CodeCountry: "BE",CodeId: 2,CodeLanguage: "fr",EnumCaption: ""},
{Caption: "",CodeCountry: "BE",CodeId: 2,CodeLanguage: "nl",EnumCaption: ""}
]
}
,
{
CodeId: 3,EnglishCaption: "",EnumCaption: "",
languages:
[
{Caption: "",CodeCountry: "DE",CodeId: 3,CodeLanguage: "de",EnumCaption: ""},
{Caption: "",CodeCountry: "GB",CodeId: 3,CodeLanguage: "en",EnumCaption: ""},
{Caption: "",CodeCountry: "BE",CodeId: 3,CodeLanguage: "nl",EnumCaption: ""}
]
}
]
I am seeking a way to optimize my code to avoid repetitive use of ng-repeat with ng-if conditions. Any suggestions on how to efficiently populate the data in its correct place considering variations in language presence within the JSON object would be appreciated.
Thank you :)