mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(radio): allow radios to check even without values
This commit is contained in:
committed by
Adam Bradley
parent
ad7885f6a4
commit
f20ae8fd3f
@@ -1,7 +1,7 @@
|
||||
import {Component, Optional, Input, Output, HostListener, EventEmitter} from 'angular2/core';
|
||||
|
||||
import {Form} from '../../util/form';
|
||||
import {isTrueProperty} from '../../util/util';
|
||||
import {isTrueProperty, isDefined} from '../../util/util';
|
||||
import {Item} from '../item/item';
|
||||
import {ListHeader} from '../list/list';
|
||||
import {RadioGroup} from './radio-group';
|
||||
@@ -69,13 +69,15 @@ export class RadioButton {
|
||||
this._item.setCssClass('item-radio', true);
|
||||
}
|
||||
|
||||
console.log(this.value);
|
||||
|
||||
if (_group) {
|
||||
_group.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.checked = !this._checked;
|
||||
check() {
|
||||
this.checked = true;
|
||||
}
|
||||
|
||||
@Input()
|
||||
@@ -105,7 +107,7 @@ export class RadioButton {
|
||||
* @private
|
||||
*/
|
||||
setChecked(val: boolean) {
|
||||
this._checked = val;
|
||||
this._checked = isTrueProperty(val);
|
||||
this._item && this._item.setCssClass('item-radio-checked', val);
|
||||
}
|
||||
|
||||
@@ -114,10 +116,10 @@ export class RadioButton {
|
||||
*/
|
||||
@HostListener('click', ['$event'])
|
||||
private _click(ev) {
|
||||
console.debug('radio, select', this.value);
|
||||
console.debug('radio, select', this.id);
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.toggle();
|
||||
this.check();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ export class RadioGroup {
|
||||
writeValue(value) {
|
||||
this.value = isDefined(value) ? value : '';
|
||||
this._buttons.forEach(button => {
|
||||
let isChecked = (button.value === this.value);
|
||||
let isChecked = button.checked;
|
||||
button.setChecked(isChecked);
|
||||
if (isChecked) {
|
||||
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-activedescendant', button.id);
|
||||
|
||||
Reference in New Issue
Block a user