小编Mar*_*aug的帖子

Angular 2:默认选中ngFor中的复选框

我正试图在我的ngFor内的复选框上设置默认值.这是我的复选框项目数组:

tags = [{
  name: 'Empathetic',
  checked: false
}, {
  name: 'Smart money',
  checked: true
}, {
  name: 'Minimal help after writing check',
  checked: false
}, {
  name: 'Easy term sheet',
  checked: true
}];
Run Code Online (Sandbox Code Playgroud)

这是我的HTML

<div class="form-group">
  <div class="form-check" *ngFor="let tag of tags;">
    <label class="form-check-label" for="tag{{tag.value}}">
      <input
        class="form-check-input"
        type="checkbox"
        id="tag{{tag.value}}"
        name="tagOptions"
        [(ngModel)]="tag.checked">
      {{tag.name}}
    </label>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

所需的结果是获得2个选中,2个未选中的框,但所有这些框都未选中.我也尝试了[checked] ="tag.checked"的不同变体,但它似乎没有做到这一点.

checkbox typescript angular2-ngmodel ngfor angular

9
推荐指数
2
解决办法
4万
查看次数

在同一个 nginx 服务器上使用 SSL 的两个 node.js 域 - 443 的重复监听选项

我已经在我的 DigitalOcean Droplet 中设置了两个 Web 应用程序,并且我正在尝试使用 SSL 加密在不同的域上运行这两个应用程序。

如果我只使用其中一个域,我可以确认一切正常,并且当我尝试同时运行这两个域时会发生错误。

nginx -t
duplicate listen options for [::]:443 in /etc/nginx/sites-enabled/hello.com:26
Run Code Online (Sandbox Code Playgroud)

/etc/nginx/sites-avilable/hello.com

server {
    server_name hello.com www.hello.com;

    location / {
            proxy_pass http://localhost:4000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }

    listen [::]:443 ssl ipv6only=on default_server; # managed by Certbot
    listen 443 ssl default_server; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/hello.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/hello.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; …
Run Code Online (Sandbox Code Playgroud)

ubuntu ssl nginx node.js digital-ocean

9
推荐指数
1
解决办法
2551
查看次数

使用 Angular 2 进行 Stripe Checkout

我正在尝试在我的 Angular 2 Web 应用程序中使用 Stripe Checkout。一切正常,直到我在收到卡令牌后尝试调用 createOrder 函数。

错误是:EXCEPTION: this.createOrder is not a function

收到令牌后如何调用 createOrder 函数?

openCheckout() {
let handler = (<any>window).StripeCheckout.configure({
  key: 'pk_test_OtZk....xbk6UQB',
  locale: 'no',
  token: function (token: any) {
    this.createOrder(token, this.cart); //THIS IS WHERE THE ERROR OCCURS
  }
});

handler.open({
  name: 'Test Store',
  description: 'Test Description',
  amount: this.cart.totalAmount,
  currency: 'nok',
  email: 'test@test.no',
  image: '../../assets/images/test.png',
  ['allow-remember-me']: false
});

this.globalListener = this.renderer.listenGlobal('window', 'popstate', () => {
  handler.close();
});
}

createOrder(token, cart) {
this.ordersService.createOrder(token, this.cart).subscribe(
  res => { …
Run Code Online (Sandbox Code Playgroud)

stripe-payments typescript angular

5
推荐指数
1
解决办法
3210
查看次数