递归模版,绑定树

递归模版

<html>
<head>
    <title>ui控件定义</title>
    <script src="jquery-1.11.2.min.js"></script>
    <script src="groot.js"></script>
</head>
<body>
<div gt-view="myview">
    <ul gt-each="list" gt-include="./templ2.html">
    </ul>
</div>
</body>
</html>
<script>
    require("./ui");
    groot.view("myview", function (vm, ve) {
        vm.list = [
            {
                dept: "移动互联网产品部",
                depts: [
                    {
                        dept: "开发一组",
                        depts:[],
                        member: [
                            {name: "张三", sex: "男"}
                            ,
                            {name: "李四", sex: "男"}
                            ,
                            {name: "王五", sex: "男"}
                        ]
                    }, {
                        dept: "开发二组",
                        depts:[],
                        member: [
                            {name: "张三", sex: "男"}
                            ,
                            {"name": "李四", sex: "男"}
                            ,
                            {name: "王五", sex: "男"}
                        ]
                    }
                ],
                member: [
                    {name: "张三", sex: "男"}
                    ,
                    {name: "李四", sex: "男"}
                    ,
                    {name: "王五", sex: "男"}
                ]
            },
            {
                dept: "生产系统集成部",
                depts: [],
                member: [
                    {name: "张三", sex: "男"}
                    ,
                    {name: "李四", sex: "男"}
                    ,
                    {name: "王五", sex: "男"}]
            }
        ];
    })
</script>

模版

<li>
    <span gt-text="{dept}"></span>
    <ul gt-each="member">
        <li><span gt-text="{name}+'--'+{sex}"></span></li>
    </ul>
    <ul gt-each="depts" gt-include="./templ2.html">
    </ul>
</li>

 

posted @ 2015-03-30 09:45  吹鱼算法  阅读(179)  评论(0编辑  收藏  举报