作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
<分区>
我在 Angular 中得到了这个对象。
$scope.columns = {
workspace: {
title: "Workspace",
type: "workspace",
activities: []
},
alerts: {
title: "Alerts",
type: "alert",
activities: []
},
main: {
title: "Main Feed",
type: "main",
activities: []
}
};
在我的 HTML 中,我需要遍历它以在我的应用程序中动态创建一系列列(想想像 Trello 这样的东西)
每个type
是对自定义指令的引用。
我正在尝试找出放置指令的最佳方式。
根据这些数据,下面的代码是否是处理动态创建这些的适当方法?
<div ng-repeat="(key, obj) in columns">
<div ng-switch on="obj.type">
<workspace-feed ng-switch-when="workspace" />
<alert-feed ng-switch-when="alert" />
<main-feed ng-switch-when="main" />
<filter-feed ng-switch-when="filter" />
</div>
</div>
我希望能够做类似... <{{obj.type}}-feed />
但我不确定这是否有效,或者是否有更好的方法来创建它。
非常感谢您的想法!
我是一名优秀的程序员,十分优秀!