Home > Web Front-end > JS Tutorial > Angular uses the operation event instruction ng-click to pass multiple parameters example

Angular uses the operation event instruction ng-click to pass multiple parameters example

亚连
Release: 2018-05-28 17:14:33
Original
1862 people have browsed it

This article mainly introduces Angular's use of the operation event command ng-click to pass multiple parameters, and analyzes the AngularJS event command and related response and processing operation skills in the form of examples. Friends in need can refer to it

This article describes the example of Angular using the operation event instruction ng-click to pass multiple parameters. Share it with everyone for your reference, the details are as follows:

<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <meta charset="UTF-8">
  <title>www.jb51.net 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>
Copy after login

The running effect is as follows:

The above is I compiled it for everyone, I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of ajax jtemplate to implement dynamic paging

403 error occurs when using jquery ajax post data in django Solution

How to use the ajax post method in Django framework

##

The above is the detailed content of Angular uses the operation event instruction ng-click to pass multiple parameters example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template