I wish to know what is the purpose of $scope.reset(); in the controller function? The reset seems to work without this code as well but documentation says to use this code and I can't understand why:
<body ng-app="myapp" ng-controller="resetController">
<label>Enter name</label><input type="text" ng-model="name"/>
<label>Enter emailid</label><input type="text" ng-model="email"/>
<button ng-click="reset()">Reset</button>
<script>
angular.module("myapp",[])
.controller("resetController", function($scope)
{
$scope.reset = function()
{
$scope.name = "";
$scope.email = "";
}
$scope.reset(); /* not sure why we need this */
});
</script>
</body>
nameandemailare bound to$scope.reset();from the controller @pixelbits . So what is its purpose then?