首页 > 代码库 > Using {{each}} in a template with an array of arrays

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

 <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