代码片段
angular.module("app.wallet", ["app.wallet.directive", "app.wallet.service"]),
angular.module("app.wallet.service", []).factory("$wallet", ["$rootScope", "$$http", "$e", "$toast", "errorMap", "$popup", "$google", function(t, e, n, a, r, o, i) {
var s = {};
return s.withdraw = function(t) {
var n = e.link({
method: "POST",
url: "/btc/withdraw",
data: {
amount: t.amount,
address: t.btcAddress
},
success: Do stuff
failure: Do other stuff
});
n.req()
}
,
s
}
]),
具体来说,我需要能够从chromes控制台调用withdraw函数。
答案 0 :(得分:1)
您可以使用angular.injector
angular.injector(['app.wallet']).get('$wallet').withdraw();
答案 1 :(得分:0)
例如,您可以通过编写window.saved = s
将任何内容附加到窗口。
然后从您的调试控制台,如果以前执行的代码,您将saved
可用:
angular.module("app.wallet", ["app.wallet.directive", "app.wallet.service"]),
angular.module("app.wallet.service", []).factory("$wallet", ["$rootScope", "$$http", "$e", "$toast", "errorMap", "$popup", "$google", function(t, e, n, a, r, o, i) {
var s = {};
s.withdraw = function(t) {
var n = e.link({
method: "POST",
url: "/btc/withdraw",
data: {
amount: t.amount,
address: t.btcAddress
},
success: Do stuff
failure: Do other stuff
});
n.req()
}
window.saved = s;
console.log('you can now acces withdraw by typing saved.withdraw in your console');
return s;
}
]),