|
@@ -1,52 +1,19 @@
|
|
|
-import { Component, Input, OnInit, forwardRef } from '@angular/core';
|
|
|
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
+import { Component, Input } from '@angular/core';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-basicinput',
|
|
|
templateUrl: './basicinput.component.html',
|
|
|
- styleUrls: ['./basicinput.component.scss'],
|
|
|
- providers: [
|
|
|
- {
|
|
|
- provide: NG_VALUE_ACCESSOR,
|
|
|
- useExisting: forwardRef(() => BasicinputComponent),
|
|
|
- multi: true
|
|
|
- }
|
|
|
- ]
|
|
|
+ styleUrls: ['./basicinput.component.scss']
|
|
|
})
|
|
|
-export class BasicinputComponent implements OnInit {
|
|
|
+export class BasicinputComponent {
|
|
|
|
|
|
@Input()
|
|
|
- type?: string = 'text';
|
|
|
+ type = 'text';
|
|
|
|
|
|
@Input()
|
|
|
- value?: string | boolean = true;
|
|
|
+ value?: string;
|
|
|
|
|
|
@Input()
|
|
|
- isDisabled?: boolean = false;
|
|
|
-
|
|
|
- @Input()
|
|
|
- meta = {};
|
|
|
-
|
|
|
- currentValue: string;
|
|
|
- propagateChange = (_: any) => {};
|
|
|
-
|
|
|
- ngOnInit() {
|
|
|
- // meta input overrides other inputs if provided
|
|
|
- ['type', 'value', 'isDisabled'].map(p => this[p] = this.meta[p] || this[p]);
|
|
|
- }
|
|
|
-
|
|
|
- onChange(value) {
|
|
|
- this.currentValue = value;
|
|
|
- this.propagateChange(value);
|
|
|
- }
|
|
|
-
|
|
|
- public writeValue(value: any): void {
|
|
|
- this.currentValue = value;
|
|
|
- }
|
|
|
-
|
|
|
- public registerOnChange(fn: any): void {
|
|
|
- this.propagateChange = fn;
|
|
|
- }
|
|
|
+ isDisabled = false;
|
|
|
|
|
|
- public registerOnTouched(fn: any): void {}
|
|
|
}
|