Angular.js:Collection / Model指令显示任意嵌套数据?

时间:2016-03-11 13:32:09

标签: angularjs

我正在寻找一个Angular.js指令,用于将任意嵌套的JSON数据显示为视图,而不事先知道该JSON的结构。

在REST端点/api/orgranisations/:organisation_id/考虑以下JSON资源:

{
    "organisation_name": "Horns and Hoofs Limited",
    "employees": [
        {
            "last_name": "Pound",
            "age": 90,
            "position": "CEO",
            "previous_projects": {
                "Marcella Vests": "member",
                "Intensivenik": "CEO"
            }
        },
        {
            "last_name": "Bender",
            "age": 31
            "position": "CTO"
            "previous_projects": {
                "12 chairs": "CTO",
                "Sons of Lt. Schmidt": "member"
            }
        },
        {
            "last_name": "Balaganov",
            "age": 25
            "position": "Head of Hoofs dpt."
            "previous_projects": {
                "Sons of Lt. Schmidt": "member"
            }
        },
        {
            "last_name": "Panikovsky",
            "age": 60
            "position": "attendant"
            "previous_projects": {
                "Blind man": "CEO"
                "Sons of Lt. Schmidt": "member"
            }
        }
    ]


}

作为一个人,你将这个JSON的元素分类为原始类型,模型和模型集合的树(我使用Backbone.js术语):

{
    "organisation_name": Primitive Type,
    "employees": Collection(EmployeeModel)
}

其中EmployeeModel是

{
    "last_name": Primitive Type,
    "age": Ptimitive Type,
    "position": Primitive Type,
    "previous_projects": Collection(PrevProjectModel)
}

其中PrevProjectModel为id: Primitive Type

我正在寻找具有以下功能的Collection和Model Angular.js指令

集合可以表示为模型表,能够执行基本操作,例如“创建模型”,“删除模型”和“拖放式排序”:

enter image description here

模型可以表示为可折叠表,如下所示:

enter image description here

到目前为止,我发现:

1 个答案:

答案 0 :(得分:1)

看看https://github.com/bfanger/angular-activerecord 它是一个像角度的模型/收集模块的骨干。我在一些项目中使用它。