mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 21:15:24 +08:00
44 lines
764 B
TypeScript
44 lines
764 B
TypeScript
import {Directive, ElementRef, Input, Output, EventEmitter} from 'angular2/core';
|
|
|
|
import {isDefined, isTrueProperty} from '../../util/util';
|
|
|
|
/**
|
|
* @name Option
|
|
*/
|
|
@Directive({
|
|
selector: 'ion-option'
|
|
})
|
|
export class Option {
|
|
private _checked: any = false;
|
|
private _value;
|
|
|
|
@Output() select: EventEmitter<any> = new EventEmitter();
|
|
|
|
constructor(private _elementRef: ElementRef) {}
|
|
|
|
@Input()
|
|
get checked() {
|
|
return this._checked;
|
|
}
|
|
|
|
set checked(val) {
|
|
this._checked = isTrueProperty(val);
|
|
}
|
|
|
|
@Input()
|
|
get value() {
|
|
if (isDefined(this._value)) {
|
|
return this._value;
|
|
}
|
|
return this.text;
|
|
}
|
|
|
|
set value(val) {
|
|
this._value = val;
|
|
}
|
|
|
|
get text() {
|
|
return this._elementRef.nativeElement.textContent;
|
|
}
|
|
}
|