angular - 选择更改后让 MatSelect 保持打开状态

标签 angular typescript angular-material

我正在使用 Angular v5 和 Angular Material。我有一个 mat-select 我想在选择一个选项后保持打开状态,因为我想通过单击特定按钮明确触发关闭。我试图将 (click)="$event.stopPropagation() 放在 mat-option 标签上,但这没有用。有什么想法吗??

我在这里创建了一个简单的例子: stackblitz demo

最佳答案

这是我找到的解决方案。希望有人受益:

<mat-select #selector placeholder="Favorite food" multiple>
    <mat-option *ngFor="let food of foods" (click)="selector.open()" [value]="food.value">
            {{ food.viewValue }}
    </mat-option>
</mat-select>

关于angular - 选择更改后让 MatSelect 保持打开状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52262781/

相关文章:

angular - Angular2如何决定是否更新或重新创建组件?

javascript - Angular 2 : Change detection inside observable

javascript - Angular 中的 Foreach 对象

typescript 我无法通过 "import"命令导入 choice.js

angular - TypeScript 阻止我将正确的约束传递给 getUserMedia

typescript - 如何在Typescript中按属性过滤对象类型的联合?

Angular Material 输入字段没有样式

javascript - 复选框未显示在 md-select multiple 中

angular - Mat Select 出现在页面底部

angular-cli - Angular2/Angular -cli : issues updating local project to Angular 4