Shared subforms

Description

The following code shows how to create shared subforms.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!-- ww  w  . java  2  s . c o  m-->

<body>
<script type="text/ng-template" id="password-form">
  <ng-form name="passwordForm">
    <div ng-show="user.password != user.password2">Passwords do not match</div>
    <label>Password</label><input ng-model="user.password" type="password" required>
    <label>Confirm Password</label><input ng-model="user.password2" type="password" required>
  </ng-form>
</script>

<form name="form1" novalidate>
  <legend>User Form</legend>
  <label>Name</label><input ng-model="user.name" required>
  <ng-include src="'password-form'"></ng-include>
</form>

</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities