[英]Angular 6 components
I have around 100 screens in my application and out of which 25 are search screens. 我的应用程序中大约有100个屏幕,其中25个是搜索屏幕。 Each search screen has multiple things in common.
每个搜索屏幕都有很多共同点。
For instance: 例如:
Screen #1: **Label** **Input type** First name: Textbox Date: Date picker Some other text boxes or radio buttons
Screen #2: **Label** **Input type** Other name: Textbox Date: Date picker Some other text boxes or radio buttons
Basically, I am moving my servlet/jsp application to Angular 6. I re-searched today how I can declare components and re-use them. 基本上,我将servlet / jsp应用程序迁移到Angular6。今天,我重新研究了如何声明组件并重新使用它们。 I haven't yet fully understood angular 6 syntax and structure and I am learning as we speak.
我还没有完全理解angular 6的语法和结构,我正在学习。
What I currently have in mind is: 我目前的想法是:
In my @Component
, i can have something like this: 在我的
@Component
,我可以有这样的内容:
@Component({
selector: 'custom_elem',
template: `
Generate html as per parameters provided by user
`
export class SubscriberComponent implements OnInit {
@Input() parameters;
}
And I pass parameters like this for Screen #1
: 我为
Screen #1
传递了这样的参数:
<custom_elem [parameters]="['First Name', 'textbox', 'Date', 'datepicker']"></custom_elem>
Notice that first element in the object is the label name
, followed by input field type
. 注意,对象中的第一个元素是
label name
,后跟input field type
。
So the generated html from the component would be: 因此,从组件生成的html将是:
First Name: <input type="text" />
Date: <input type="date" />
Using this parameters I want to generate html code in my component. 使用此参数,我想在组件中生成html代码。
Q1. Q1。 Is this possible?
这可能吗?
Q2. Q2。 If yes to above, then how?
如果是,请问如何解决? [Please explain since today's my first day of experiencing angular, I have no background working with this]
[请解释一下,因为今天是我体验角度的第一天,我对此没有工作背景。
Let me know in comments, if any further details are required. 如果需要任何其他详细信息,请在评论中告知我。 Thank you in advance.
先感谢您。
请点击此链接,这将为您提供具有不同控件类型的动态表单,您只需要将QuestionBase类作为参数传递给带有动态表单的Angular可重用组件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.