angulaJS来自对象的分层选择选项

时间:2016-08-09 19:59:53

标签: angularjs

我正在使用angularJS,我的对象是vm.parentList2(如下所示) 想要以分层格式显示选择选项,如下所示

Foundation of Information Technology
Life Skills
    Thinking Skills
    writing Skills

我正在尝试使用代码,

<select ng-model="selected" ng-options="c as c.subject_group_name group by c.categoryType.subject_group_name 
        for c in categories 
        track by c.s_gid" class="form-control" multiple size="10"></select>



vm.parentList2 = [{
    "s_gid": "10",
    "m_s_p_id": "1",
    "subject_group_name": "Foundation of Information Technology",
    "parent_id": "0",
    "sname": ""
}, {
    "s_gid": "11",
    "m_s_p_id": "2",
    "subject_group_name": "Life Skills",
    "parent_id": "0",
    "sname": "",
    "child": [{
        "s_gid": "15",
        "m_s_p_id": "2",
        "subject_group_name": "Thinking Skills",
        "parent_id": "11",
        "sname": "Th.sk"
    }, {
        "s_gid": "15",
        "m_s_p_id": "2",
        "subject_group_name": "writing Skills",
        "parent_id": "11",
        "sname": "Th.sk"
    }]
}]

0 个答案:

没有答案