aboutsummaryrefslogtreecommitdiff
path: root/app/js/controllers.js
diff options
context:
space:
mode:
authorNicolas Bornand <nicolas74@gmail.com>2014-05-11 10:54:55 +0200
committerNicolas Bornand <nicolas74@gmail.com>2014-05-11 10:54:55 +0200
commit481dc29aa7225d7aa7a00b2690165245a4065252 (patch)
treea126488543379874bb1163754ff632f5e4951fa1 /app/js/controllers.js
parent64b7faae30bb530b7fb4bd839735e8d4b3d6decb (diff)
parent9e579f32a7818f78f568089638fdcf8a06f579e6 (diff)
downloadplayGraph-481dc29aa7225d7aa7a00b2690165245a4065252.tar.gz
playGraph-481dc29aa7225d7aa7a00b2690165245a4065252.tar.bz2
playGraph-481dc29aa7225d7aa7a00b2690165245a4065252.zip
Merge origin/master
Conflicts: app/js/services.js
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