角度6:如何将html文件包含到组件中?

编程入门 行业动态 更新时间:2024-10-28 00:14:33
本文介绍了角度6:如何将html文件包含到组件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在servlet环境中,我们可以包含以下任何jsp:

In a servlet environment we can include any jsp like this :

<%@include file=" 'path-to-jsp' " %>

在我的有角项目中,我有一个HTML表单,其中包含许多组件. 我想将此表单包含在两个组件中(创建和更新).

In my angular project I have a html form with many components in it. I want to include this form in 2 components (create and update).

user-form.html:

user-form.html :

<input type=".."...> <input type=".."...> <input type=".."...> <select>...

create-userponent.html:

create-userponent.html:

<form> // insert content of 'user-form.html' at compile time <button>Create User</button> </form>

update-userponent.html:

update-userponent.html:

<form> // insert content of 'user-form.html' at compile time <button>Update User</button> </form>

在Angular 2+中有实现此目的的方法吗?

Is there a way of accomplishing this in Angular 2+ ?

注意:我使用反应形式

推荐答案

您可以将此用户表单作为模板添加到视图中.这样绑定也将起作用 像下面的例子一样

You can add this user-form as a template in your view. in this way binding will also work Like the following example

<user-form [state] = 'Create/Update'></user-form> <button>Create/Update</button>

,用户组件将状态作为输入来检查它是否处于编辑或创建状态. 并在UserFormComponent中将选择器称为用户窗体",并在当前组件中包括UserFormComponent.

and the user component will take the state as an input to check whether it's in edit or create state. And mention the selector as "user-form" in the UserFormComponent and also include UserFormComponent in your current component.

更多推荐

角度6:如何将html文件包含到组件中?

本文发布于:2023-11-28 19:54:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643746.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   组件   角度   文件   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!