Skip to content

Commit

Permalink
feat(controls): Added number control support
Browse files Browse the repository at this point in the history
  • Loading branch information
joaogarin committed Sep 11, 2016
1 parent 4e8252a commit 130f2f9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { FormGroup, FormControl } from '@angular/forms';
styles: [``],
template: `
<div [formGroup]="inputGroup">
<label>{{label}}</label>
<select formControlName="item" [(ngModel)]="value">
<label for="BooleanSelect">{{label}}</label>
<select id="BooleanSelect" formControlName="item" [(ngModel)]="value">
<option [ngValue]="true">True</option>
<option [ngValue]="false">False</option>
</select>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Angular 2 decorators and services
*/
import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';

@Component({
// The selector is what angular internally uses
selector: 'cb-number-control',
styles: [``],
template: `
<div [formGroup]="inputGroup">
<label for="numberElement">{{label}}</label>
<input id="numberElement" type="number" [(ngModel)]="value" formControlName="item" required/>
</div>
`,
})
export class NumberControlComponent {
@Input() label: string;
@Input() value: string;
@Input() inputGroup: FormGroup;

constructor() { }

ngOnInit() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { FormGroup } from '@angular/forms';
styles: [``],
template: `
<div [formGroup]="inputGroup">
<label>{{label}}</label>
<input type="text" [(ngModel)]="value" formControlName="item" />
<label for="stringElement">{{label}}</label>
<input id="stringElement" type="text" [(ngModel)]="value" formControlName="item" />
</div>
`,
})
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/controls/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StringControlComponent } from './base/stringControl/stringControl.component.ts';
import { BooleanControlComponent } from './base/booleanControl/booleanControl.component.ts';
import { NumberControlComponent } from './base/numberControl/numberControl.component.ts';

export const defaultControls = {
// Basic
Expand All @@ -11,6 +12,10 @@ export const defaultControls = {
control: BooleanControlComponent,
nested: false,
},
number: {
control: NumberControlComponent,
nested: false,
},
};

export { ControlsModule } from './controls.module.ts';

0 comments on commit 130f2f9

Please sign in to comment.