Angular service wrapper for the OWF's widget javascript library.
Provides a service wrapper around the global OWF
object. You may now inject owf
into a controller or any other angular component. This allows for easier mocking of the OWF global in unit tests. The owf
object points to OWF
thus you can write calls like owf.Launcher.launch(...)
as would normally against OWF
.
Includes an optional owf-app
directive. This directive will ensure that OWF's ready event is fired before launching your angular app. Just replace your normal ng-app="myModule"
with owf-app="MyModule"
.
Modifies various asynchronous OWF methods so they now return $q promises. If the original callback would have been called with one argument, the promise will be resolved to that value. If the callback would have been called with multiple arguments, the promise will be resolved with an array of those argument values. Currently the only promise-ified methods are:
OWF.getOpenedWidgets()
OWF.Launcher.launch(...)
OWF.RPC.getWidgetProxy(...)
Install with Bower or download the the files directly from the repo.
bower install angular-owf --save
Add angular-owf.js
to your index.html. This library also depends on the OWF Bower package and you'll need to add its owf-widget-min.js
from it or from OWF directly.
Add cgOwf
as a module dependency for your module.
angular.module('your_app', ['cgOwf']);
Then inject and use the owf
service.
function myController($scope,owf){ // <-- Inject owf
owf.Launcher.launch({
universalName: 'widget.company.com'
}).then(function(){
console.log('Widget launched!');
});
}
When running outside of an OWF contained widget, this service will instead contain various noop versions of the standard OWF methods. The noop-ed methods include OWF.ready()
, OWF.getOpenedWidgets()
, OWF.Launcher.launch()
, OWF.Launcher.getLaunchData()
, OWF.RPC.registerFunctions()
, OWF.Eventing.publish()
, OWF.Eventing.subscribe()
, and OWF.Eventing.unsubscribe()
.
owf-app
so that the app will be automatically bootstrapped/launched when not running inside OWF.