Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Kalpesh300's full-sized avatar
🎯
Focusing

Kalpesh Shingala Kalpesh300

🎯
Focusing
View GitHub Profile
@Kalpesh300
Kalpesh300 / custom-dropdown.component.ts
Created December 12, 2019 16:46
Custom Dropdown Component
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[];
@Kalpesh300
Kalpesh300 / custom-dropdown.component.html
Created December 12, 2019 16:55
Custom Dropdown Component
<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">
@Kalpesh300
Kalpesh300 / custom-dropdown.component.ts
Created December 12, 2019 17:00
Custom Dropdown Component
export class CustomDropdownComponent implements OnInit,
ControlValueAccessor {
options: string[];
selectedOption: string;
constructor() { }
ngOnInit() {
this.options = [
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 {
@Kalpesh300
Kalpesh300 / app.component.html
Created December 12, 2019 17:14
App Component
<app-custom-dropdown [formControl]="dropdownControl"></app-custom-dropdown>
@Kalpesh300
Kalpesh300 / custom-dropdown.component.ts
Created December 12, 2019 17:20
Custom Dropdown Component
export class CustomDropdownComponent implements OnInit,
ControlValueAccessor {
options: string[];
selectedOption: string;
constructor() { }
ngOnInit() {
this.options = [
@Kalpesh300
Kalpesh300 / custom-dropdown.component.html
Created December 12, 2019 17:24
Custom Dropdown Component
<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
@Kalpesh300
Kalpesh300 / custom-dropdown.component.ts
Created December 12, 2019 17:28
Custom Dropdown Component
export class CustomDropdownComponent implements OnInit,
ControlValueAccessor {
options: string[];
selectedOption: string;
onChange: (_: any) => {};
constructor() { }
@Kalpesh300
Kalpesh300 / custom-dropdown.component.ts
Created December 12, 2019 17:42
Custom Dropdown Component
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),
@Kalpesh300
Kalpesh300 / app.component.html
Created December 12, 2019 17:58
Custom Dropdown Control
<app-custom-dropdown [formControl]="dropdownControl"></app-custom-dropdown>