mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-21 23:41:49 -05:00
26 lines
775 B
JavaScript
26 lines
775 B
JavaScript
exports.command = function inject (deps, script, callback) {
|
|
this.executeAsync(
|
|
`let args = Array.prototype.slice.call(arguments,0);
|
|
|
|
return function(deps, done) {
|
|
let injector = angular.element('body').injector();
|
|
let loaded = deps.map(d => {
|
|
if (typeof(d) === "string") {
|
|
return injector.get(d);
|
|
} else {
|
|
return d;
|
|
}
|
|
});
|
|
(${script.toString()}).apply(this, loaded).then(done);
|
|
}.apply(this, args);`,
|
|
[deps],
|
|
function handleResult (result) {
|
|
if (typeof callback === 'function') {
|
|
callback.call(this, result.value);
|
|
}
|
|
}
|
|
);
|
|
|
|
return this;
|
|
};
|