我一直在試圖瞭解如何爲我的應用程序設置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