Display User Input in Angular JS

Display User Input in Angular JS

Write an angular JS code to display FirstName and Lastname entered by the user into the respective textbox and display output.

BCA 2023 Sem - V

Solution :

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="myCtrl">
<h2>Enter Your Details</h2>

<label>First Name:</label>
<input type="text" ng-model="firstname" placeholder="Enter First Name"><br><br>

<label>Last Name:</label>
<input type="text" ng-model="lastname" placeholder="Enter Last Name"><br><br>

<h3>Output:</h3>
<p>{{firstname}} {{lastname}}</p>

<script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
        $scope.firstname = '';
        $scope.lastname = '';
    });
</script>