标签:
元素被点击时调用方法或者表达式:
<!doctype html> <html ng-app="myApp"> <head> <link rel="stylesheet" href="//cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script> </head> <body> <div ng-controller="CounterController"> <button ng-click="count = count + 1" ng-init="count=0"> Increment </button> count: {{count}} <button ng-click="decrement()"> Decrement </button> <div> </body> </html>
angular.module(‘myApp‘, []) .controller(‘CounterController‘, function($scope) { $scope.decrement = function() { $scope.count = $scope.count - 1; }; });
标签:
原文地址:http://www.cnblogs.com/ByronWu12345/p/4853302.html