首页 > 代码库 > [Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup
[Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup
The ngModelGroup
directive allows you to group together related inputs so that you structure the object represented by the form in a useful and predictable way. ngModelGroup
is often used in combination with fieldset
as they mostly represent the same idea of “grouping together inputs.”
<form name="myForm2" #formRef2="ngForm" (ngSubmit)="onSubmit(formRef2.value)"> <fieldset ngModelGroup="login"> <legend>Login:</legend> Username: <input type="text" name="username" ngModel required> Password: <input type="password" name="password" ngModel requried> </fieldset> </form> <pre> form value: {{formRef2.value | json}} form valid: {{formRef2.valid | json}} </pre>
Github
[Angular2 Form] Group Inputs in Angular 2 Forms with ngModelGroup
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。