Hi SUJAYS,
Check this example. Now please take its reference and correct your code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', []);
app.controller('MyController', function ($scope, $sce) {
$scope.GetTime = function () {
$scope.Test = DisplayTime($scope.Name);
$scope.Message = $sce.trustAsHtml($scope.Test);
};
});
function DisplayTime(name) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd < 10) { dd = '0' + dd; }
if (mm < 10) { mm = '0' + mm; }
var date = dd + '/' + mm + '/' + yyyy;
return "Name : " + name + "<br />Time : " + date;
}
</script>
</head>
<body>
<div ng-app="MyApp" ng-controller="MyController">
<input type="text" ng-model="Name" />
<input type="button" ng-click="GetTime()" value="Submit" />
<hr />
<span ng-bind-html="Message"></span>
</div>
</body>
</html>
Demo