Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

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>


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post