This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-custom-dropdown', | |
templateUrl: './custom-dropdown.component.html', | |
styleUrls: ['./custom-dropdown.component.scss'] | |
}) | |
export class CustomDropdownComponent implements OnInit { | |
options: string[]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="btn-group" dropdown> | |
<button id="button-basic" dropdownToggle type="button" | |
class="btn btn-primary dropdown-toggle" | |
aria-controls="dropdown-basic"> | |
{{ selectedOption }} <span class="caret"></span> | |
</button> | |
<ul id="dropdown-basic" *dropdownMenu class="dropdown-menu" | |
role="menu" aria-labelledby="button-basic"> | |
<li role="menuitem" *ngFor="let option of options"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomDropdownComponent implements OnInit, | |
ControlValueAccessor { | |
options: string[]; | |
selectedOption: string; | |
constructor() { } | |
ngOnInit() { | |
this.options = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { FormControl, Validators } from '@angular/forms'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-custom-dropdown [formControl]="dropdownControl"></app-custom-dropdown> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomDropdownComponent implements OnInit, | |
ControlValueAccessor { | |
options: string[]; | |
selectedOption: string; | |
constructor() { } | |
ngOnInit() { | |
this.options = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="btn-group" dropdown> | |
<button id="button-basic" dropdownToggle type="button" | |
class="btn btn-primary dropdown-toggle" | |
aria-controls="dropdown-basic"> | |
{{ selectedOption }} <span class="caret"></span> | |
</button> | |
<ul id="dropdown-basic" *dropdownMenu class="dropdown-menu" | |
role="menu" aria-labelledby="button-basic"> | |
<li role="menuitem" *ngFor="let option of options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomDropdownComponent implements OnInit, | |
ControlValueAccessor { | |
options: string[]; | |
selectedOption: string; | |
onChange: (_: any) => {}; | |
constructor() { } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, forwardRef } from '@angular/core'; | |
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; | |
@Component({ | |
selector: 'app-custom-dropdown', | |
templateUrl: './custom-dropdown.component.html', | |
styleUrls: ['./custom-dropdown.component.scss'], | |
providers: [{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => CustomDropdownComponent), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-custom-dropdown [formControl]="dropdownControl"></app-custom-dropdown> |
OlderNewer