blob: 4817deae90ac82538b5ea0f85656d8f00064545e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { Input, Component } from "@angular/core";
import { ValidationComponent } from './validation.component';
import { Subject } from 'rxjs/Subject';
import { IValidatableComponent } from './validatable.interface';
export abstract class ValidatableComponent implements IValidatableComponent {
// Each ValidatableComponent should handle the style in case of error, according to this boolean
public valid = true;
// Each ValidatableComponent will notify when the value is changed.
public notifier: Subject<string>;
constructor() {
this.notifier = new Subject();
}
public abstract getValue(): any;
// Each ValidatableComponent should call the valueChanged on value changed function.
protected valueChanged = (value: any): void => {
this.notifier.next(value);
}
}
|