Skip to content

Instantly share code, notes, and snippets.

@tomaszkubacki
Created May 4, 2017 13:58
Show Gist options
  • Save tomaszkubacki/af03a58025c6f4766ad82cc750d33eae to your computer and use it in GitHub Desktop.
Save tomaszkubacki/af03a58025c6f4766ad82cc750d33eae to your computer and use it in GitHub Desktop.
combobox in angulardart
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