AngularJSで、マウスイベントのUP・Downを使います。
【手順】
1.『AngularJS1.5.8のダウンロード方法』の手順で、AngularJS1.5.8をダウンロードしておきます。
2.『index.html』というファイルを作成。
3.『index.html』を以下の様に入力。
<!doctype html>
<html ng-app="mainModule">
<head>
<script src="angular.min.js"></script>
<script>
var mainModule = angular.module('mainModule',[]);
var sampleController = function($scope) {
$scope.onMouseUp = function() {
$scope.eventResult = 'マウスがアップされました。';
};
$scope.onMouseDown = function() {
$scope.eventResult = 'マウスがダウンされました。';
};
};
mainModule.controller('sampleController', ['$scope', sampleController]);
</script>
</head>
<body ng-controller="sampleController">
<div style="width:100px; height:100px; background-color:pink;"
ng-mouseup="onMouseUp()"
ng-mousedown="onMouseDown()"></div>
{{eventResult}}
</body>
</html>
4.ダウンロードした『angular.min.js』と『index.html』を同一ディレクトリに配置します。
5.『index.html』をブラウザで開きます。
6.以下の様に表示されれば成功です。
以上です。


0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。