<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<button id ='b1'> 点我</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,$compile) {
$scope.carname = "Volvo";
$scope.f = function(){alert(2)};
$compile(angular.element("#b1").attr("ng-click","f()"))($scope);
});
</script>
</body>
</html>
转载于:https://www.cnblogs.com/shunzdd/p/5585978.html