Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. var a = false,
  2. b = false;
  3. $scope.$on("eventA", function () {
  4. a = true;
  5. if (b)
  6. performTask();
  7. });
  8. $scope.$on("eventB", function () {
  9. b = true;
  10. if (a)
  11. performTask();
  12. });
  13. var performTask = function () {
  14. ................
  15. };
  16.  
  17. var a = false, b = false;
  18. $scope.$on("eventA", function(){ a = true; });
  19. $scope.$on("eventB", function(){ b = true; });
  20. $scope.$watch(
  21. function() { return a && b; },
  22. function(newval, oldval) {
  23. if (newval) { performTask(); }
  24. }
  25. );
  26.  
  27. var events = { a: false, b: false };
  28. $scope.$on("eventA", function(){ events.a = true; });
  29. $scope.$on("eventB", function(){ events.b = true; });
  30. $scope.$watch(
  31. function() {
  32. var result = true;
  33. for (var key in events) {
  34. result = result && events[key];
  35. }
  36. return result;
  37.  
  38. },
  39. function(newval, oldval) {
  40. if (newval) { performTask(); }
  41. }
  42. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement