Output form data as json

Description

The following code shows how to output form data as json.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w  w  w.  j  a va 2  s. c o  m-->
<body>
  <h1>User Info</h1>
  <label>E-mail</label>
  <input type="email" ng-model="user.email">
  <label>Last name</label>
  <input type="text" ng-model="user.lastName">
  <label>First name</label>
  <input type="text" ng-model="user.firstName">
  <label>Website</label>
  <input type="url" ng-model="user.website">
  <label>Description</label>
  <textarea ng-model="user.description"></textarea>
  <label>Password</label>
  <input type="password" ng-model="user.password">
  <label>Password (repeat)</label>
  <input type="password" ng-model="repeatPassword">
  <label>Roles</label>
  <label class="checkbox"><input type="checkbox" ng-model="user.admin"> Is Administrator</label>
  
  <pre ng-bind="user | json"></pre>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities