AngularJs Forms
AngularJs Forms : An AngularJs Forms contains the input fields known as controls. Controls are used by user to enter the data.
AngularJs Forms example
Example
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myController"> <form novalidate> Name:<br> <input type="text" ng-model="user.name"><br> Email:<br> <input type="email" ng-model="user.email" > <br> <button ng-click="reset()">Reset</button> </form> <div>form = {{user }}</div> <div>master = {{master}}</div> </div> <script> var app = angular.module('myApp', []); app.controller('myController', function($scope) { $scope.master = {name:"Tani",email:"tani@ymaill.com"}; $scope.update = function(user){ $scope.master = angular.copy(user); } $scope.reset = function() { $scope.user = angular.copy($scope.master); }; $scope.reset(); }); </script> </body> </html> |
Advertisements