Created
May 4, 2017 13:58
-
-
Save tomaszkubacki/af03a58025c6f4766ad82cc750d33eae to your computer and use it in GitHub Desktop.
combobox in angulardart
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 'dart:html'; | |
import 'package:angular2/angular2.dart'; | |
import 'package:logging/logging.dart'; | |
@Component(selector: 'combobox-control', | |
template: """ | |
<select [(ngModel)]="selectedValue" > | |
<option *ngFor="let obj of source" [ngValue]="obj">{{displayGetter(obj)}}</option> | |
</select> | |
""") | |
class ComboboxControl implements OnInit { | |
final Logger log = new Logger('ComboboxControl'); | |
@Input() | |
DisplayValueGetter displayGetter = (dynamic o)=> o?.toString(); | |
List _source = [new Object()]; | |
List get source => _source; | |
String placeholder = ''; | |
int currentIndex = 0; | |
@Input() | |
void set source(List sourceValues){ | |
_source = sourceValues; | |
} | |
List filteredValues = []; | |
@Output() | |
EventEmitter selectedValueChange = new EventEmitter<dynamic>(); | |
Object _selectedValue; | |
Object get selectedValue => _selectedValue; | |
@Input() | |
void set selectedValue(Object newVal){ | |
if(newVal != selectedValue ){ | |
_selectedValue = newVal; | |
selectedValueChange.emit(_selectedValue); | |
} | |
} | |
@override | |
ngOnInit() { | |
// TODO: implement ngOnInit | |
} | |
} | |
typedef String DisplayValueGetter(dynamic o); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment