Angular 2 和 stripe.js

Angular 2 and stripe.js

有没有人尝试将 stripe.js 与 Angular 2 一起使用?我正在尝试显示一个标准的条纹支付表单,但是 "Pay" 按钮没有被渲染并且没有显示任何错误。我将不胜感激任何想法。 我猜测条纹形式必须在 Angular 2 模板之外以某种方式声明。

@Component({
  selector: '...',
  moduleId: module.id,
  providers: [],
  directives: [],
  styles: [`
  `],
  template: `
...
        <div class="row">
            <div class="col-sm-12">
                <form action="/charge" method="POST">
                    <script
                        src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                        data-key="pk_test_...."
                        data-name="...."
                        data-description="2 widgets"
                        data-amount="2000"
                        data-locale="auto">
                    </script>
                </form>
            </div>
        </div>
    </section>
  `
})

您不能将 <script> 标签添加到 Angular2 组件的模板,它们会被删除。

另见 https://github.com/angular/angular/issues/4903

script tags should be in index.html page, or potentially loaded via a script loader (ie SystemJS) - script tags in templates will not work.