Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var a = false,
- b = false;
- $scope.$on("eventA", function () {
- a = true;
- if (b)
- performTask();
- });
- $scope.$on("eventB", function () {
- b = true;
- if (a)
- performTask();
- });
- var performTask = function () {
- ................
- };
- var a = false, b = false;
- $scope.$on("eventA", function(){ a = true; });
- $scope.$on("eventB", function(){ b = true; });
- $scope.$watch(
- function() { return a && b; },
- function(newval, oldval) {
- if (newval) { performTask(); }
- }
- );
- var events = { a: false, b: false };
- $scope.$on("eventA", function(){ events.a = true; });
- $scope.$on("eventB", function(){ events.b = true; });
- $scope.$watch(
- function() {
- var result = true;
- for (var key in events) {
- result = result && events[key];
- }
- return result;
- },
- function(newval, oldval) {
- if (newval) { performTask(); }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement