我一直在试图了解如何为我的应用程序设置Stripe,但是在实现模块时遇到问题。通常,当使用模块时,我会要求它在文件的顶部能够使用它,但是当我在paymentCtrl文件中执行它时,它不起作用,我得到以下两个错误:我应该在哪里声明它为了我能够使用它?就像你看到我对此很新,并且想要了解如何构建这个以便支付工作。尝试加载需要模块时出错
错误:
Unexpected token.
和
Failed to instantiate module paymentController due to: Error: [$injector:nomod] Module 'paymentController' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
paymentCtrl:
angular.module('paymentController', [])
var stripe = require('stripe')('sk_test_....');
.controller('paymentCtrl', function($scope) {
});
app.js:
angular.module('userApp', ['appRoutes', 'userControllers', 'userServices', 'ngAnimate', 'mainController', 'authServices', 'managementController', 'paymentController'])
.config(function($httpProvider) {
$httpProvider.interceptors.push('AuthInterceptors');
});
然后我得到的错误: 要求不以paymentCtrl.js定义 :1 – Oscar
我认为需要对服务器端。你需要在前端加载'stripe'库。在你的html中使用bower,webpack或应该可以工作。 – sh977218