aboutsummaryrefslogtreecommitdiff
path: root/app/js/controllers.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/js/controllers.js')
-rw-r--r--app/js/controllers.js53
1 files changed, 33 insertions, 20 deletions
diff --git a/app/js/controllers.js b/app/js/controllers.js
index e79dfa9..97e6366 100644
--- a/app/js/controllers.js
+++ b/app/js/controllers.js
@@ -3,22 +3,31 @@
/* Controllers */
var p = new Point(1,2);
+
+
app.controller('pointCtrl', function($scope, $http, pathService){
- var constList = [
- {x: 10, y:20},
- {x: 20, y:30},
- {x: 40, y:50},
- {x: 60, y:60},
- {x: 100, y:120},
- {x: 150, y:300},
- {x: 150, y:340}
- ];
-
- var playlist = pathService.computePlaylist(dummyPoints,constList, 60);
-
- $scope.line=constList;
+
$scope.points=dummyPoints;
- $scope.playlist=playlist;
+ $scope.line = [];
+
+ var update = function(newPoints, newLine) {
+ if(newLine.length > 0) {
+ $scope.playlist=pathService.computePlaylist(newPoints, newLine, 60);
+ }
+ }
+
+ $scope.$watch('points', function(newVal, oldVal) {
+ console.log("r")
+ update(newVal, $scope.line);
+ }, true);
+
+ $scope.$watch('line', function(newVal) {
+ update($scope.points, newVal);
+ }, true);
+
+
+// $scope.line=constList;
+
$scope.getColor = function(point) {
if (playlist.indexOf(point) == -1) {
@@ -27,11 +36,15 @@ app.controller('pointCtrl', function($scope, $http, pathService){
return "red"
}
}
-
-
- /*$http.get('data.json').then( function (response) {
- console.log(response.data.points);
- $scope.points=JSON.parse(response.data.points);
- });*/
+ $scope.foo = function (event) {
+ console.log("foobar");
+
+ $scope.points.push({
+ x: 250,
+ y: 250
+ });
+ };
+
+
}); \ No newline at end of file