【发布时间】:2016-09-09 04:10:36
【问题描述】:
我想使用 angularJS 在 html 画布中创建一些圆圈。 我知道如何使用 javascript 来做同样的事情,但我是 angularJS 的新手,非常感谢任何帮助。
代码:
<title>Home Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
</head>
<body>
<div ng-app="myapp" ng-controller="myctrl">
<canvas id="canvas" width="2100" height="900"
style="border: 1px solid #d3d3d3;">
</canvas>
</div>
<script>
var $scope;
var app = angular.module('myapp', []);
myapp.controller("myctrl", function($scope){
var c1 = document.getElementById("canvas");
var ctx = c1.getContext("2d");
ctx.beginPath();
ctx.arc(500, 500, 50, 0, 2 * Math.PI, false);
ctx.lineWidth = 0.2;
ctx.stroke();
ctx.fill();
})
</script>
</body>
【问题讨论】:
-
非常感谢您的帮助.. 但我想知道是否有办法使用我的代码。