checkbox extends IonInputContainer

This commit is contained in:
Tim Lancina
2015-07-16 18:21:31 -05:00
parent a352d1ac46
commit e947f32898
4 changed files with 24 additions and 21 deletions

View File

@ -9,6 +9,7 @@ export * from 'ionic/components/item/item'
export * from 'ionic/components/item/item-group' export * from 'ionic/components/item/item-group'
export * from 'ionic/components/form/form' export * from 'ionic/components/form/form'
export * from 'ionic/components/form/text-input' export * from 'ionic/components/form/text-input'
export * from 'ionic/components/form/tap-input'
export * from 'ionic/components/form/label' export * from 'ionic/components/form/label'
export * from 'ionic/components/list/list' export * from 'ionic/components/list/list'
export * from 'ionic/components/modal/modal' export * from 'ionic/components/modal/modal'

View File

@ -8,6 +8,7 @@ import {
} from 'angular2/angular2'; } from 'angular2/angular2';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {IonInputContainer} from '../form/form';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
import {IonicComponent, IonicView} from '../../config/annotations'; import {IonicComponent, IonicView} from '../../config/annotations';
import {Icon} from '../icon/icon'; import {Icon} from '../icon/icon';
@ -34,7 +35,7 @@ import {Icon} from '../icon/icon';
'<content></content>' + '<content></content>' +
'</div>' '</div>'
}) })
export class Checkbox extends Ion { export class Checkbox extends IonInputContainer {
_checkbox: CheckboxInput; _checkbox: CheckboxInput;
@ -52,7 +53,7 @@ export class Checkbox extends Ion {
} }
} }
registerCheckbox(checkboxDir) { registerInput(checkboxDir) {
if (this._checkbox != null) { if (this._checkbox != null) {
throw 'Only one <input type="checkbox"> is allowed per <ion-checkbox>' throw 'Only one <input type="checkbox"> is allowed per <ion-checkbox>'
} }
@ -73,17 +74,15 @@ export class Checkbox extends Ion {
} }
} }
@Directive({
selector: 'input[type=checkbox]' // export class CheckboxInput {
}) // constructor(
export class CheckboxInput { // elementRef: ElementRef,
constructor( // @Optional() @Parent() container: Checkbox,
elementRef: ElementRef, // @Optional() control: NgControl
@Optional() @Parent() container: Checkbox, // ) {
@Optional() control: NgControl // this.elementRef = elementRef;
) { // this.control = control ? control : null;
this.elementRef = elementRef; // container && container.registerCheckbox(this);
this.control = control ? control : null; // }
container && container.registerCheckbox(this); // }
}
}

View File

@ -1,13 +1,16 @@
import {Parent, Ancestor, Optional, ElementRef, Attribute} from 'angular2/angular2'; import {Parent, Ancestor, Optional, ElementRef, Attribute, Directive} from 'angular2/angular2';
import {IonInput} from './form'; import {IonInput} from './form';
import {IonicApp} from '../app/app'; import {IonicApp} from '../app/app';
import {Content} from '../content/content'; import {Content} from '../content/content';
import {Checkbox} from '../checkbox/checkbox';
@Directive({
selector: 'input[type=checkbox],input[type=radio]'
})
export class TapInput extends IonInput { export class TapInput extends IonInput {
constructor( constructor(
@Optional() @Parent() container: Input, @Optional() @Parent() container: Checkbox, //TODO have this be either Checkbox or Radio
@Optional() @Ancestor() scrollView: Content, @Optional() @Ancestor() scrollView: Content,
@Attribute('type') type: string, @Attribute('type') type: string,
elementRef: ElementRef, elementRef: ElementRef,

View File

@ -11,7 +11,7 @@ import {
List, Item, ItemGroup, ItemGroupTitle, List, Item, ItemGroup, ItemGroupTitle,
Toolbar, Toolbar,
Icon, Icon,
Checkbox, CheckboxInput, Switch, Checkbox, TapInput, Switch,
Input, TextInput, Label, Input, TextInput, Label,
Segment, SegmentButton, SegmentControlValueAccessor, Segment, SegmentButton, SegmentControlValueAccessor,
RadioGroup, RadioButton, SearchBar, RadioGroup, RadioButton, SearchBar,
@ -56,13 +56,13 @@ export const IonicDirectives = [
forwardRef(() => SegmentButton), forwardRef(() => SegmentButton),
forwardRef(() => SegmentControlValueAccessor), forwardRef(() => SegmentControlValueAccessor),
forwardRef(() => Checkbox), forwardRef(() => Checkbox),
forwardRef(() => CheckboxInput),
//Checkbox, Switch //Checkbox, Switch
//RadioGroup, RadioButton, SearchBar, //RadioGroup, RadioButton, SearchBar,
// Input // Input
forwardRef(() => Input), forwardRef(() => Input),
forwardRef(() => TextInput), forwardRef(() => TextInput),
forwardRef(() => TapInput),
forwardRef(() => Label), forwardRef(() => Label),
// Nav // Nav