I would like to create my own select component by extending Angular material component mat-select
and use my custom app-select
component like below
<app-select>
<mat-option>Value1</mat-option>
<mat-option>Value2</mat-option>
<mat-option>Value3</mat-option>
<mat-option>Value4</mat-option>
</app-select>
I have made an example in stackblitz where I almost got it to work. The issue Im having is that the dropdown panel wont close after selecting an option.
https://stackblitz.com/edit/angular-vdyjcy?file=src%2Fapp%2Fselect%2Fselect.component.html
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-select',
templateUrl: './select.component.html',
styleUrls: ['./select.component.css']
})
export class SelectComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<mat-form-field>
<mat-select>
<mat-option>
None
</mat-option>
<ng-content></ng-content>
</mat-select>
</mat-form-field>