繁体   English   中英

Angular 6组件

[英]Angular 6 components

我的应用程序中大约有100个屏幕,其中25个是搜索屏幕。 每个搜索屏幕都有很多共同点。

例如:

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

基本上,我将servlet / jsp应用程序迁移到Angular6。今天,我重新研究了如何声明组件并重新使用它们。 我还没有完全理解angular 6的语法和结构,我正在学习。

我目前的想法是:

在我的@Component ,我可以有这样的内容:

@Component({
  selector: 'custom_elem',
  template: `
Generate html as per parameters provided by user
  `
export class SubscriberComponent implements OnInit {  
  @Input() parameters;
}

我为Screen #1传递了这样的参数:

<custom_elem [parameters]="['First Name', 'textbox', 'Date', 'datepicker']"></custom_elem>

注意,对象中的第一个元素是label name ,后跟input field type

因此,从组件生成的html将是:

First Name: <input type="text" />
Date: <input type="date" />

使用此参数,我想在组件中生成html代码。

Q1。 这可能吗?
Q2。 如果是,请问如何解决? [请解释一下,因为今天是我体验角度的第一天,我对此没有工作背景。

注意:我也遇到过角度元素,并且我不想使用它,因为我读到它还没有被浏览器完全支持。 因此,我将无法在组织中批准它。

如果需要任何其他详细信息,请在评论中告知我。 先感谢您。

请点击此链接,这将为您提供具有不同控件类型的动态表单,您只需要将QuestionBase类作为参数传递给带有动态表单的Angular可重用组件

暂无
暂无

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

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