Home  >  Article  >  Web Front-end  >  Angular uses ng-click to upload multiple parameters at the same time

Angular uses ng-click to upload multiple parameters at the same time

php中世界最好的语言
php中世界最好的语言Original
2018-05-08 14:32:521634browse

This time I will bring you Angular’s ​​use of ng-click to upload multiple parameters at the same time. What are the precautions for Angular to use ng-click to upload multiple parameters at the same time? The following are Let’s take a look at practical cases.

<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <meta charset="UTF-8">
  <title>angular ng-click用于操作事件的指令</title>
  <script src="angular.min.js"></script>
  <!--
    事件指令:Angular封装的用于操作事件的指令
    通常是ng-[event]来命名指令,如ng-click表示单击事件
    Angular中的事件处理,需要将处理函数挂载到对应控制器的$scope上
  -->
</head>
<body>
  <p ng-controller="myCtrl">
    <button ng-click="fn1()">点击执行</button>
    <button ng-click="fn2($event)">点击执行,附带事件对象$event</button>
    <button ng-click="fn2($event, &#39;tom&#39;)">点击执行,多个参数</button>
  </p>
<script>
  var app = angular.module("myApp", [])
    .controller("myCtrl", ["$scope", function($scope) {
      $scope.fn1 = function() {
        alert("事件执行");
      }
      $scope.fn2 = function(event,name) {
        console.log("事件执行了.", event, name);
      }
    }]);
</script>
</body>
</html>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of the steps for EL to obtain context parameters

JS implements the function of exchanging left and right lists

The above is the detailed content of Angular uses ng-click to upload multiple parameters at the same time. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn