简体   繁体   English

在Angular JS中使用HTML版本控制渲染动态UI

[英]Render dynamic UI with HTML versioning in Angular JS

I have a challenging requirement. 我有一个挑战性的要求。 The requirement is as follows. 要求如下。

  1. We are designing a UI today with 10 UI elements. 今天,我们正在设计一个包含10个UI元素的UI。
  2. Users are creating few records. 用户正在创建少量记录。
  3. After a month, a new release comes and it has 12 UI elements on screen. 一个月后,有一个新版本发布,屏幕上有12个UI元素。
  4. When the user creates new records, he should see 12 UI elements, when he opens an old record he should see 10 elements. 用户创建新记录时,他应该看到12个UI元素,而打开旧记录时,他应该看到10个元素。

In order to achieve this, I thought, we could store the version with which the record was created and render the HTML belonging to that version. 为了实现这一目标,我认为,我们可以存储创建记录的版本,并呈现属于该版本的HTML。 But, this will unnecessarily keep increasing the project size, as if the code gets 100 revisions, that much of HTML duplicates will be present. 但是,这将不必要地继续增加项目的大小,就像代码得到100个修订一样,将显示许多HTML重复项。

I thought of using "switch-case" or "if-else" statements in front end, but it will slow the UI as too much heavy lifting is done by JS. 我曾想过在前端使用“ switch-case”或“ if-else”语句,但由于JS完成了太多繁重的工作,这会减慢UI的速度。

Please suggest a way to do this requirement with JS or jQuery or Angular. 请提出一种使用JS或jQuery或Angular满足此要求的方法。 Any one framework is also fine, until it will work. 任何一个框架都可以,直到可以正常工作为止。

Thanks a lot for your responses in advance, 非常感谢您的提前回复,

Look at a framework called angular-schema-forms. 看一下称为角模式形式的框架。 You write no HTML with this framework. 您没有使用此框架编写HTML。 Instead you pass it a JSON object that has the fields you want to display and their corresponding display as attributes. 相反,您传递给它一个JSON对象,该对象具有要显示的字段及其对应的显示作为属性。 It comes preloaded with its own templates for all common controls and also allows you to write your own. 它预装了用于所有常见控件的自己的模板,还允许您编写自己的模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM