我试图在我的按钮被鼠标悬停时调用一个函数。这段代码应该可以工作,但它不会触发我在控制器中定义的函数。
JavaScript代码
angular.module("myApp", [])
.controller('myCtrl', function($scope) {
$scope.alertHi = function() {
alert('hi');
};
});
HTML代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example72-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="myCtrl">
<button ng-mouseover="alertHi()">
Alert Hi
</button>
</div>
</body>
</html>
我有一个掠夺者
http://plnkr.co/edit/ZyQUi266hFsnvPhcTcpn?p=preview
有什么想法吗?谢谢!
答案 0 :(得分:5)
您-code.js
protected static void KnockDownWall(CellInfo[,] cells, Tuple<int, int> target, Tuple<int, int> neighbour) {
var offsetTarget = Tuple.Create(neighbour.Item1 - target.Item1, neighbour.Item2 - target.Item2);
cells[target.Item1, target.Item2] ^= targetLookup[offsetTarget.Item1+1, offsetTarget.Item2+1];
cells[neighbour.Item1, neighbour.Item2] ^= neighborLookup[offsetTarget.Item1+1, offsetTarget.Item2+1];
}
您需要加载代码:
angular.module("myApp", [])
.controller('myCtrl', function($scope) {
$scope.alertHi = function() {
alert('hi');
};
});
答案 1 :(得分:3)
您未在页面上加载app.js.
<script src="./app.js"></script>