我试图生成一个表单,其中每个条目都是启用或禁用的规则。
我希望它看起来像:
[X] Color is blue
[X] Size is at least [ 50 ]
[X] Speed is at least [ 20 ] for [ 7 ] [ minutes ]
[ Submit ]
其中[X]表示复选框[number]是一个spinbox / edit,[text]是一个列表框。
我想从模板生成此规则集。主要问题是如何在AngularJS中更好地完成非均匀模板扩展?它完全适用于这类任务吗?
此源代码模型类似于(Coffeescript语法简洁):
color_blue:
template: "Color is {{color}}"
params:
color:
type: "list"
values: ["red", "blue" ]
default: 1
size_at_least:
template: "Size is at least {{size}}"
params:
size:
type: "Number"
min: 30
max: 60
default: 50
speed_at_least:
template: "Speed is at least {{speed}} for {{time}} {{time_units}}"
params:
speed:
type: "Number"
min: 0
max: 60
default: 0
time:
type: "int"
min: 0
max: 20
default: 7
unit:
type: "list"
values: ["seconds", "minutes", "hours" ]
default: 1
我绝对可以使用JQuery并轻松生成这些规则,但我目前正在学习AngularJS,并且更愿意从这个实际任务中学到一些东西。