Using {{each}} in a template with an array of arrays

时间:2022-06-23 12:03:16

 

 <script id="DeptTemplate" type="text/x-jquery-tmpl">
        <li>
            Title:${Name}
            {{each Emp}}
            <br />${$index+1}:${$value}
            {{/each}}
        </li>
    </script>
    <ul id="deptList"></ul>
    <script>
        var deptlist = [
        { Name: "销售部", Emp: ["张三", "李四", "李四", "李四", "李四", "李四"] },
        { Name: "网络部", Emp: ["王二", "李四", "李四", "李四"] }
        ];
        $("#DeptTemplate").tmpl(deptlist).appendTo("#deptList");
    </script>

 

 

Using {{each}} in a template with an array of arrays