ModifyArrayObserver length is 0

Hi :slight_smile:
I have currently a problem with iterating over an array which transformed to a ModifyArrayObserver.

When I use the following code:

<div repeat.for="informationText of informationTexts">
  <span>${informationText.language}</span>
</div>

I won’t get anything shown in the frontend even though there will be entries in the array because the length is 0. I am not completely sure what is going on but maybe someone can help me.
In my JS I loop over an array with forEach and filter by languages to have them unique. It looks like this:

languages.forEach((language) => {
  const languageTexts: Text[] = activeTexts.filter((text: Text) => {
    return text.language === language;
  });
  this.informationTexts[language] = languageTexts;
});

How can I render my informationTexts in my view?
(I came from here: https://github.com/aurelia/binding/issues/42)
Thanks in advance.

1 Like

Maybe also important is the versions of aurelia I am using:

    "aurelia-binding": "1.5.0",
    "aurelia-bootstrapper": "2.1.1",
    "aurelia-configuration": "1.0.17",
    "aurelia-dialog": "1.0.0-rc.1.0.3",
    "aurelia-fetch-client": "1.1.3",
    "aurelia-framework": "1.1.4",
    "aurelia-history-browser": "1.0.0",
    "aurelia-i18n": "1.6.2",
    "aurelia-loader-webpack": "^2.2.1",
    "aurelia-logging-console": "1.0.0",
    "aurelia-pal-browser": "1.3.0",
    "aurelia-polyfills": "1.2.2",
    "aurelia-router": "1.3.0",
    "aurelia-table": "1.1.3",
    "aurelia-templating": "1.4.2",
    "aurelia-templating-binding": "1.3.0",
    "aurelia-templating-resources": "1.4.0",
    "aurelia-templating-router": "1.1.0",
    "aurelia-validation": "1.1.1",

Can you try the following:

this.informationTexts = languages.map((language) => {
  return activeTexts.filter((text: Text) => text.language === language);
});

I think the current code is not building array informationTexts properly.

1 Like

Thank you very much for your help :blush:

This worked to have data in my view :partying_face:

When I log this.informationTexts in the attached-method it is an empty ModifyArrayObserver this time. Before there was data in it but the length was 0.

1 Like