Last active
December 18, 2015 02:19
-
-
Save xjamundx/5710275 to your computer and use it in GitHub Desktop.
oj3.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// oj3 implementation | |
angular.module('odesk').factory('oj3', function() { | |
return { | |
widgets: odesk.mediator.widgets, | |
trigger: function($scope, event, data) { | |
// i don't know, we aren't an instance | |
}, | |
registerWidget: function(name, $scope) { | |
// this won't quite work, because $scope doesn't talk OJ3 events | |
oj3.registerWidget(name, $scope); | |
}, | |
subscribe: function(widget, event, cb) { | |
// something like this might actually work | |
oj3.widgets[widget][event].subscribe(cb); | |
} | |
} | |
}); | |
angular.module('MCCtrl').controller(function($scope, oj3) { | |
oj3.registerWidget('MCCtrl', $scope); | |
oj3.trigger("update", "We are great"); | |
oj3.subscribe("AutoCompleter", "update" function() { | |
alert('auto-completer updated!'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment