Working with events and functions

WAP to input two numbers and show sum of those numbers on same web page using AngularJS

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

Number 1 <input type="text" ng-model="num1" ng-keyup="sum()"><br>
Number 2 <input type="text" ng-model="num2" ng-keyup="sum()"><br>

Sum is {{s}}

</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.num1 = 0;
    $scope.num2=0;
    $scope.s=0;
    $scope.sum=function()
    {
    $scope.s=parseInt($scope.num1)+parseInt($scope.num2);
    };
});
</script>

</body>
</html>

Comments