I am trying to find sum of two numbers entered in text boxes and display result in third text box, using controller in AngularJS. But I am not getting the answer. Here's the code that I have tried:
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1> ANGULAR JS</h1>
<script src="https://code.angularjs.org/1.6.9/angular.js"></script>
<script src="E:\akansha\angular-1.7.6\angular.js"></script>
<script src="E:\akansha\angular-1.7.6\angular.min.js"></script>
<div ng-app="sumApp" ng-controller="sumCtrl">
Enter first number<input type="number" ng-model="num1"><br> Enter second number<input type="number" ng-model="num2"><br> Sum
<input type="text" ng-model="sum"> {{num1+" "+num2}}
</div>
<script>
var app = angular.module('sumApp', []);
app.controller('sumCtrl', function($scope) {
var a = $scope.num1;
var b = $scope.num2;
var c = a + b;
$scope.sum = c;
});
</script>
</body>
</html>
Please tell me where I am wrong.
Sum<input type="text" mg-model="sum">. Change themg-modeltong-model.