'Forms in Angular.js

I've been studying Angular.js for my term exams and was working on the following code related to Angular.js forms.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular-csp.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    <title>Practical 12</title>
</head>
<body>
    
    <div ng-app="formApp" ng-controller="formCtrl">
        <form name="festForm" novalidate ng-submit="sendForm(x)">
            <h2>Registration form for tech event</h2>
            <table>
                <tr>
                    <td>
                        <label for="fname">First Name</label>
                        <input type="text" name="fname" id="fname" ng-model="x.fname" >
                        <!-- <span ng-show="festForm.fname.$error.required">*enter first name</span> -->
                    </td>
                </tr>
                <tr>
                    <input type="submit" value="SUBMIT">
                </tr>
            </table>
        </form>

        <p>{{userdata}}</p>
    </div>
    <script>
        var app=angular.module("formApp",[])
        app.controller("formCtrl",function($scope){
            $scope.userdata="";
            $scope.sendForm=function(fest){
                $scope.msg="Form Validated"
                $scope.userdata=angular.copy(fest);
                console.log(fest)
            }
            
        })
    </script>
</body>
</html>

Following is the output of the following code

enter image description here I am not able to understand the flow how my argument fest passed in the sendform function gets converted into javascript object.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source