小编Gvs*_*hil的帖子

Angular AutoComplete 将值作为 [Object Object] 返回

我的要求是在输入框中显示选定的值,并将选定的 Id 和值获取到 .ts 文件中。因为我需要 Id 和 Value,所以我将选项值直接绑定到 [value]。但是如果我这样做,它就会被打印为 [Object Object]。

<mat-form-field appearance="outline" class="w-100">
            <mat-label>Enter Hotel Name</mat-label>
            <input type="text" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
            <mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectedclient($event)">
                <mat-option *ngFor="let option of clients; let i = index" [value]="option">
                    {{ option.name }}
                  </mat-option>
            </mat-autocomplete>
            <mat-icon matSuffix>location_on</mat-icon>
          </mat-form-field>
Run Code Online (Sandbox Code Playgroud)

Ts文件

    options = [
        { id: 1, name: 'One'},
        { id: 2, name: 'Two'},
        { id: 3, name: 'Three'}
       ];

selectedclient(event) {
     console.log(event.option.value);
   }
Run Code Online (Sandbox Code Playgroud)

Stackblitz 编辑器网址:https ://stackblitz.com/edit/angular-mat-select-data-n4tvmj

angular angular-material-6

13
推荐指数
1
解决办法
1万
查看次数

如何公开上传到 Amazon s3 的文件

我正在按照本教程将文件从 php 上传到亚马逊 s3。教程很好,但是我有一个小问题,所有上传的文件都必须手动公开才能从互联网上看到它们。有没有办法自动化这个?

上传.php

<?php 
    // This file demonstrates file upload to an S3 bucket. This is for using file upload via a
    // file compared to just having the link. If you are doing it via link, refer to this:
    // https://gist.github.com/keithweaver/08c1ab13b0cc47d0b8528f4bc318b49a
    //
    // You must setup your bucket to have the proper permissions. To learn how to do this
    // refer to:
    // https://github.com/keithweaver/python-aws-s3
    // https://www.youtube.com/watch?v=v33Kl-Kx30o

    // I will be using composer to install the needed AWS …
Run Code Online (Sandbox Code Playgroud)

php amazon-s3 amazon-web-services

4
推荐指数
1
解决办法
2549
查看次数