Radio cleanup, create @IonicDirective

This commit is contained in:
Adam Bradley
2015-06-18 18:54:58 -05:00
parent 8d8149a143
commit 2f7e6c0495
4 changed files with 108 additions and 109 deletions

View File

@@ -7,7 +7,7 @@ import {bind} from 'angular2/di';
import {ViewController} from '../view/view-controller';
import {SwipeHandle} from './swipe-handle';
import {ModeComponent} from '../../config/component';
import {IonicComponentNEW} from '../../config/component';
export class PaneController {
@@ -87,10 +87,7 @@ export class PaneController {
}
@ModeComponent({
selector:'ion-pane',
classId: 'nav'
})
@IonicComponentNEW(Pane)
@View({
template: `
<template pane-anchor></template>
@@ -102,6 +99,14 @@ export class PaneController {
directives: [PaneAnchor, PaneContentAnchor, SwipeHandle]
})
export class Pane {
static get config() {
return {
selector:'ion-pane',
classId: 'nav'
}
}
constructor(viewCtrl: ViewController, elementRef: ElementRef) {
this.domElement = elementRef.domElement;
viewCtrl.panes.add(this);

View File

@@ -1,28 +1,29 @@
import {ElementRef} from 'angular2/angular2'
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
import {View} from 'angular2/src/core/annotations_impl/view';
import {ControlGroup, ControlDirective} from 'angular2/forms'
import {IonicComponent} from 'ionic/config/component'
//import {ControlGroup, ControlDirective} from 'angular2/forms'
import {IonicDirective, IonicComponentNEW} from 'ionic/config/component';
@Component({
selector: 'ion-radio-group'
})
@View({
template: `<content></content>`
})
@IonicDirective(RadioGroup)
export class RadioGroup {
static get config() {
return {
selector: 'ion-radio-group'
}
}
constructor(
elementRef: ElementRef,
cd:ControlDirective
elementRef: ElementRef//,
//cd:ControlDirective
) {
this.domElement = elementRef.domElement
this.config = RadioGroup.config.invoke(this)
this.controlDirective = cd;
cd.valueAccessor = this; //ControlDirective should inject CheckboxControlDirective
// this.config = RadioGroup.config.invoke(this)
// this.controlDirective = cd;
// cd.valueAccessor = this; //ControlDirective should inject CheckboxControlDirective
this.domElement.classList.add('list');
@@ -85,17 +86,8 @@ export class RadioGroup {
}
}
new IonicComponent(RadioGroup, {})
@Component({
selector: 'ion-radio',
hostListeners: {
'^click': 'buttonClicked($event)'
},
properties: [
'value'
]
})
@IonicComponentNEW(RadioButton)
@View({
template: `
<div class="item-content">
@@ -113,12 +105,24 @@ new IonicComponent(RadioGroup, {})
`
})
export class RadioButton {
static get config() {
return {
selector: 'ion-radio',
hostListeners: {
'^click': 'buttonClicked($event)'
},
properties: [
'value'
]
}
}
constructor(
@Ancestor() group: RadioGroup,
elementRef: ElementRef
) {
this.domElement = elementRef.domElement
this.config = RadioButton.config.invoke(this)
this.domElement = elementRef.domElement;
this.domElement.classList.add('item')
this.domElement.setAttribute('aria-checked', true)
@@ -145,7 +149,3 @@ export class RadioButton {
}
}
new IonicComponent(RadioButton, {
})

View File

@@ -1,22 +1,22 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms';
//import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms';
import {RadioGroup, RadioButton, Content, Button, List} from 'ionic/ionic';
@Component({ selector: 'ion-view' })
@View({
templateUrl: 'main.html',
directives: [FormDirectives].concat([RadioGroup, RadioButton, List, Content, Button])
directives: [RadioGroup, RadioButton, List, Content, Button]
})
export default class IonicApp {
constructor() {
console.log('IonicApp Start')
var fb = new FormBuilder();
this.form = fb.group({
preferredApple: ['mac', Validators.required],
});
// var fb = new FormBuilder();
// this.form = fb.group({
// preferredApple: ['mac', Validators.required],
// });
}
}