Angular 角度可观测链
我所做的是:Angular 角度可观测链,angular,asynchronous,angular2-observables,unsubscribe,Angular,Asynchronous,Angular2 Observables,Unsubscribe,我所做的是: A B C D E F ---------------------- 2 4 6 2 5 7 3 3 6 0 6 8 3 6 5 1 6 8 5 0 1 1 1 5 1 2 2 0 1 5 WHY I AM Subscribing B to A , C-> B , because on change of A , B will change and on
A B C D E F
----------------------
2 4 6 2 5 7
3 3 6 0 6 8
3 6 5 1 6 8
5 0 1 1 1 5
1 2 2 0 1 5
WHY I AM Subscribing B to A , C-> B , because on change of A , B will change and on change of B -> C will change (its like excel) where there are formulas on each field and change of each field other field will change
ObservableB[i] = ObervableA[i];
ObservableC[i] = ObservableB[i].pipe();
ObservableD[i] = obbservableC[i].pipe(
Map(res => res +1)
);
ObservableE[i] = ObservableD[i].pipe();
ObservableF[i] = ObservableE[i].pipe();
及
同样,对于ObserveB,ObserveC,ObserveD,ObserveE,ObserveF
现在我想要的是:
选择ObserveA或任何其他下拉列表时,其他下拉列表值应更改
例如,如果我选择
注意:下拉列表是多选的
DropdownA选择的值:2,3
因此,其他下拉列表值应自动重置(重置是指其他下拉列表的可用选项应更改)为
B下拉列表的可用选项应为:4,3,6
ObserveC = 6,5 (only unique values in drop down)
ObserveD = 2,0,1
ObserveE = 5,6 (only unique values in drop down)
ObserveF = 7,8 (only unique values in drop down)```
Is this is achievable ??
下面的代码怎么样 排除.pipe.ts:
@Pipe({name:'exclude'})
导出类ExcludePipe实现PipeTransform{
转换(值:any[],…参数:any[]):any{
返回值.filter(x=>![].concat.apply([],args).includes(x))
}
}
unique.pipe.ts:
@Pipe({name:'unique'})
导出类UIQuePipe实现PipeTransform{
onlyUnique=(值,索引,self)=>self.indexOf(值)==index;
变换(值:任意[]:任意{
返回值.filter(this.onlyUnique)
}
}
app.component.ts:
@组件(…)
导出类AppComponent{
observableA=of([2,4,6,2,5,7])
observableB=of([3,3,6,0,6,8])
observableC=of([3,6,5,1,6,8])
可观测=of([5,0,1,1,1,5])
可观察对象=of([1,2,2,0,1,5])
}
app.component.html:
{{item}}
{{item}}
{{item}}
{{item}}
{{item}}
以下代码如何
排除.pipe.ts:
@Pipe({name:'exclude'})
导出类ExcludePipe实现PipeTransform{
转换(值:any[],…参数:any[]):any{
返回值.filter(x=>![].concat.apply([],args).includes(x))
}
}
unique.pipe.ts:
@Pipe({name:'unique'})
导出类UIQuePipe实现PipeTransform{
onlyUnique=(值,索引,self)=>self.indexOf(值)==index;
变换(值:任意[]:任意{
返回值.filter(this.onlyUnique)
}
}
app.component.ts:
@组件(…)
导出类AppComponent{
observableA=of([2,4,6,2,5,7])
observableB=of([3,3,6,0,6,8])
observableC=of([3,6,5,1,6,8])
可观测=of([5,0,1,1,1,5])
可观察对象=of([1,2,2,0,1,5])
}
app.component.html:
{{item}}
{{item}}
{{item}}
{{item}}
{{item}}
非常感谢您的努力,但有两件事我想提醒您:1)我这么做的原因是bec:“ObservableB[i]=ObervableA[i];”当一个更改的值时,B将根据类似excel 2的公式进行评估;第二,不仅是更改其他下拉列表的下拉列表值,还应更改其通用值,任何下拉列表的更改都会导致其他下拉列表的值发生变化3)您在每一行的基础上增加了一个可观察值???如果您不理解,请告诉我,我必须创建类似excel的结构,其中我有公式一,每一列的值将根据同一行或其他列计算,我能完成其他的事情,但下拉式的东西是左感谢你的努力认真但有两件事我想提醒你:1)我为什么这么做是因为bec:“observablea[I]=ObervableA[I];”当更改值时,B将根据类似于excel 2)的公式进行评估,其次不仅是更改其他下拉列表的下拉列表值,还应更改其通用值,任何下拉列表的更改都会导致其他下拉列表的值发生变化3)您在每一行的基础上增加了一个可观察值???如果您不理解,请告诉我,我必须创建类似excel的结构,其中我有公式一,每一列的值将根据同一行或其他列计算,我可以实现其他的事情,但下拉的东西是左
ObserveC = 6,5 (only unique values in drop down)
ObserveD = 2,0,1
ObserveE = 5,6 (only unique values in drop down)
ObserveF = 7,8 (only unique values in drop down)```
Is this is achievable ??