Pass Parameter value under event in angular JS:-
We can pass param directly under the calling function which will be received by called function:-
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl" >
<input type="text" ng-model="num" />
<br>
<br>
<input type="button" value="sq" ng-click="fun('sq')">
<input type="button" value="cube" ng-click="fun('cb')">
<br>
{{res}}
</div>
<script type="text/javascript">
angular.module('myApp',[]).controller("myCtrl",function($scope)
{
$scope.num=0;
$scope.fun=function(arg){
if(arg=="sq")
$scope.res= eval($scope.num)*eval($scope.num);
else
$scope.res= eval($scope.num)*eval($scope.num)* eval($scope.num);
}
})
</script>
</body>
</html>
We can pass param directly under the calling function which will be received by called function:-
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl" >
<input type="text" ng-model="num" />
<br>
<br>
<input type="button" value="sq" ng-click="fun('sq')">
<input type="button" value="cube" ng-click="fun('cb')">
<br>
{{res}}
</div>
<script type="text/javascript">
angular.module('myApp',[]).controller("myCtrl",function($scope)
{
$scope.num=0;
$scope.fun=function(arg){
if(arg=="sq")
$scope.res= eval($scope.num)*eval($scope.num);
else
$scope.res= eval($scope.num)*eval($scope.num)* eval($scope.num);
}
})
</script>
</body>
</html>
POST Answer of Questions and ASK to Doubt