Is there a short and simple way to pass an RxJS Subject or BehaviorSubject to an an Angular 2 directive for two-way binding? The long way to do it would be as follows:
A possible solution is a sublcass of BehaviorSubject:
class ModelSubject extends BehaviorSubject {
constructor(initialValue: T) {
super(initialValue);
}
set model(value: T) {
this.next(value);
}
get model(): T {
return this.value;
}
}
Usage:
Component-Class:
name = new ModelSubject('');
Component-Template: