How to display a nested array in a template

Va Bo

I'm trying to iterate in a array nested in an other array. My collection data :

 "roles" : [
    {
        "id" : 126987,
        "name" : "Ergonomic Wooden Fish",
        "containers" : [
                 {
                     "id" : "2654213845" ,
                     "name" : "FirstCont",
                     "rights" : [
                        {
                            "id" : "54684213",
                            "name: "FirstRight"

                        }
                       ]
            }
          ]
   }
 ]

JS/Helpers

Template.myTemplate.helpers({
  'roles': function() {
   return Roles.find({});
  }
});

HTML

<template name='myTemplate'>
  {{#each roles}}
     {{id}}
     {{name}}
     {{#each containers}}
        {{name}}
     {{/each}}
   {{/each}}
</template>

I can display name and id from roles, but not name from containers.

I try to visualize the object back but I can't.

What am I doing wrong?

Faysal Ahmed

create another helper containers.

containers: function(){
     return this.containers;
 }

and then keep your template as it is.

<template name='myTemplate'>
{{#each roles}}
 {{id}}
 {{name}}
 {{#each containers}}
    {{name}}
 {{/each}}
{{/each}}

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to display the nested array data in react native from API?

分類Dev

How to display nested array in codeigniter (country - state - city hierarchy)

分類Dev

How to use a nested typedef in a template?

分類Dev

How to handle nested template variables?

分類Dev

How to display the error in .ejs template

分類Dev

How to display array in label?

分類Dev

How to Display multidimensional Array?

分類Dev

How to use a nested class as type in a template class?

分類Dev

How to set nested block template to an attribute

分類Dev

How to set nested block template to an attribute

分類Dev

How to display a kendo template inside another?

分類Dev

MongoDB how to filter in nested array

分類Dev

How to get a nested array into rowData

分類Dev

how to query nested array of objects by also filtering nested array of nested array in mongo

分類Dev

How to sort nested Firebase DB's nested object array

分類Dev

How to pass array of objects as a parameter to template

分類Dev

how to define an array in template (not use .ts)

分類Dev

In elasticsearch, how to group by value inside nested array

分類Dev

How to update nested array in React state?

分類Dev

How to make an array of multiple nested objects?

分類Dev

How to find data from nested array?

分類Dev

How to append to a nested array in a JSONB column

分類Dev

How to access the variables in a nested class with array object?

分類Dev

How to parse nested json array in android

分類Dev

How do I update an Array nested in a Hash?

分類Dev

How to make array of SKSpriteNode and then display them on the screen?

分類Dev

How to display this JS array in a HTML list?

分類Dev

How to display json array values in single UITableVIewCell

分類Dev

How can I display an array of objects?

Related 関連記事

  1. 1

    How to display the nested array data in react native from API?

  2. 2

    How to display nested array in codeigniter (country - state - city hierarchy)

  3. 3

    How to use a nested typedef in a template?

  4. 4

    How to handle nested template variables?

  5. 5

    How to display the error in .ejs template

  6. 6

    How to display array in label?

  7. 7

    How to Display multidimensional Array?

  8. 8

    How to use a nested class as type in a template class?

  9. 9

    How to set nested block template to an attribute

  10. 10

    How to set nested block template to an attribute

  11. 11

    How to display a kendo template inside another?

  12. 12

    MongoDB how to filter in nested array

  13. 13

    How to get a nested array into rowData

  14. 14

    how to query nested array of objects by also filtering nested array of nested array in mongo

  15. 15

    How to sort nested Firebase DB's nested object array

  16. 16

    How to pass array of objects as a parameter to template

  17. 17

    how to define an array in template (not use .ts)

  18. 18

    In elasticsearch, how to group by value inside nested array

  19. 19

    How to update nested array in React state?

  20. 20

    How to make an array of multiple nested objects?

  21. 21

    How to find data from nested array?

  22. 22

    How to append to a nested array in a JSONB column

  23. 23

    How to access the variables in a nested class with array object?

  24. 24

    How to parse nested json array in android

  25. 25

    How do I update an Array nested in a Hash?

  26. 26

    How to make array of SKSpriteNode and then display them on the screen?

  27. 27

    How to display this JS array in a HTML list?

  28. 28

    How to display json array values in single UITableVIewCell

  29. 29

    How can I display an array of objects?

ホットタグ

アーカイブ