1

I'm relatively experienced with Angular having written many directives, but I have a new requirement where I have to build a query-by-example form into which a user can enter different search criteria. My problem is that I do not know ahead of time what the possible criteria will be. This criteria information will be coming from the server via an ajax request and can differ per user. Thus I will need to dynamically construct a suitable user interface based on the information I get from the server.

I have built individual directives suitable for capturing the search criteria (for example a custom calendar control for date criteria) but I am unsure of the best approach to adding these directives to a form dynamically. Is this even possible in Angular?

I have built something like this before in jQuery but its not so clear to me how I would best do this in an 'Angular way'?

Any suggestions would be most appreciated!

4

1 回答 1

0

您可以表达为模型到视图投影的所有内容都可以在 AngularJS 中实现。

我认为在这里您可以制作一个由“查询参数”组成的模型。他们每个人都有过滤器构建器的名称、类型和数据。例如,对于“选择”类型,数据可以包含可供选择的所有可能值的列表。

然后,您使用 ng-repeat 遍历“查询参数”列表,根据其类型以不同方式呈现每个控件。就这样。

如果我对任务的理解有误,请提供更多信息。

于 2013-07-05T18:07:59.303 回答