From 4b6720b2f57c50096addcbabf139b97b384da21e Mon Sep 17 00:00:00 2001 From: lmirelmann Date: Sun, 8 Mar 2015 23:49:35 +0100 Subject: [PATCH] several updates to the Angular 1 version --- app.jsx | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app.jsx b/app.jsx index efbb527..91d6e10 100644 --- a/app.jsx +++ b/app.jsx @@ -16,17 +16,17 @@ directive("myCalendar", function() { replace: true, template:`
- - - + + +
- - - +
+ {{day}}
- +
+
@@ -53,14 +53,14 @@ directive("myCalendarCell", function() { replace: true, scope: true, template: ` -
-
- {{hour}}:00 +
+
+ {{::hour}}:00
-
+
...
-
+
{{status.searchResults.options}}
results
@@ -69,9 +69,9 @@ directive("myCalendarCell", function() { link: function(scope, element, attrs) { scope.day = attrs.day; scope.hour = attrs.hour; - scope.status = {}; }, controller: function($scope, $rootScope, $timeout) { + $scope.status = {}; $scope.showSpinner = function() { return $scope.status.isSearching; } @@ -93,19 +93,23 @@ directive("myCalendarCell", function() { return 'bad-results' } } + return ''; } $scope.cellClicked = function() { - delete $scope.status.searchResults; + $scope.status.searchResults = null; $scope.status.isSearching = true; // Simulate an AJAX request: $timeout(function() { $scope.status.isSearching = false; $scope.status.searchResults = {options: Math.floor(Math.random() * 5)}; - }, randomMillis()); + }, randomMillis(), false).then(localDigest); } $scope.$on('allSearchRequested', function() { $scope.cellClicked(); }); + function localDigest() { + $scope.$digest(); + } } } }).