mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
chore(build): rename ionic directory to src and update all references in the build process.
This commit is contained in:
59
src/components/option/option.ts
Normal file
59
src/components/option/option.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import {Directive, ElementRef, Input, Output, EventEmitter} from '@angular/core';
|
||||
|
||||
import {isPresent, isTrueProperty} from '../../util/util';
|
||||
|
||||
/**
|
||||
* @name Option
|
||||
* @description
|
||||
* `ion-option` is a child component of `ion-select`. Similar to the native option element, `ion-option` can take a value and a checked property.
|
||||
*
|
||||
* @demo /docs/v2/demos/item-sliding/
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'ion-option'
|
||||
})
|
||||
export class Option {
|
||||
private _checked: any = false;
|
||||
private _value;
|
||||
|
||||
/**
|
||||
* @input {any} Event to evaluate when option has changed
|
||||
*/
|
||||
@Output() select: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
constructor(private _elementRef: ElementRef) {}
|
||||
|
||||
/**
|
||||
* @input {boolean} Whether or not the option is already checked and selected
|
||||
*/
|
||||
@Input()
|
||||
get checked() {
|
||||
return this._checked;
|
||||
}
|
||||
|
||||
set checked(val) {
|
||||
this._checked = isTrueProperty(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @input {any} The value of the option
|
||||
*/
|
||||
@Input()
|
||||
get value() {
|
||||
if (isPresent(this._value)) {
|
||||
return this._value;
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
set value(val) {
|
||||
this._value = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
get text() {
|
||||
return this._elementRef.nativeElement.textContent;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user