1. 程式人生 > >Angular 點選事件

Angular 點選事件

<div ng-controller="asd">
<button type="button" ng-click="alert()">asdsa </button>
</div>

----------------------------------------------------------

<script src="js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var  app = angular.module("myapp", []); 
app.controller('asd', function($scope) {   

$scope.alert = function() {
alert("你好")
}

})
</script>

----------------------------------------------------

點選按鈕彈出 你好     點選事件的繫結  ng-click="alert()"