aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/compiler.ngdoc
diff options
context:
space:
mode:
authorKeir Mierle2013-04-21 16:37:53 -0700
committerPete Bacon Darwin2013-04-22 12:52:08 +0100
commit8c75b5f55aa80e03c455e1efcdba216f1e51bd05 (patch)
tree3824849fae63dfc82e48f28da1cac67c49a5e6ae /docs/content/guide/compiler.ngdoc
parent2d66ccd593c1ee240dddef333ad304a68842c065 (diff)
downloadangular.js-8c75b5f55aa80e03c455e1efcdba216f1e51bd05.tar.bz2
docs(compiler): fix variable scope in drag sample
Note that without this fix, if you add a second draggable element, the two instances clobber each other since there is only one set of startx/starty/x/y variables. Here is an example: http://plnkr.co/edit/aGrLXcIo2SuaePuAdfmQ?p=preview. On the surface it looks like it would be fine because you only have one mouse but in practice the start position jumps when you start dragging. Here it is fixed: http://plnkr.co/edit/VuvPasuumtCeiVRisYKQ?p=preview
Diffstat (limited to 'docs/content/guide/compiler.ngdoc')
-rw-r--r--docs/content/guide/compiler.ngdoc2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/content/guide/compiler.ngdoc b/docs/content/guide/compiler.ngdoc
index 9915107b..d315df45 100644
--- a/docs/content/guide/compiler.ngdoc
+++ b/docs/content/guide/compiler.ngdoc
@@ -70,8 +70,8 @@ Here is a directive which makes any element draggable. Notice the `draggable` at
<file name="script.js">
angular.module('drag', []).
directive('draggable', function($document) {
- var startX=0, startY=0, x = 0, y = 0;
return function(scope, element, attr) {
+ var startX = 0, startY = 0, x = 0, y = 0;
element.css({
position: 'relative',
border: '1px solid red',