我正在使用primeNg的动态对话框,我必须将2个变量从组件A传递到组件B中,而组件B是我从A动态打开的
showSkillDetailModal(categoryId: number, skillId: number) {
const ref = this.dialogService.open(SkillDetailsComponent, {
width: '70%',
data: {
categoryId: categoryId,
skillId: skillId
}
});
}
这是用于打开动态对话框SkillDetailsComponent的代码,我发送的数据位于数据数组-> categoryId&skillId
constructor(
public ref: DynamicDialogRef,
public config: DynamicDialogConfig,
private selfService: SelfDataService
) {}
ngOnInit() {
this.selfService.getMySkillList(categoryId, skillId).subscribe(response => {
}, error => {
console.log(error);
})
}
但是我无法在SkillDetailsComponent中获得这两个变量... 有什么想法可以前进吗?
答案 0 :(得分:0)
d = {'redFish': {'redFish': 'inf', 'blueFish': 9, 'twoFish': 10, 'oneFish': 6}, 'blueFish': {'redFish': 9, 'blueFish': 'inf', 'twoFish': 11, 'oneFish': 10}, 'twoFish': {'redFish': 10, 'blueFish': 11, 'twoFish': 'inf', 'oneFish': 8}, 'oneFish': {'redFish': 6, 'blueFish': 10, 'twoFish': 8, 'oneFish': 'inf'}}
lowestPair = ['name1', 'name2', float('inf')]
for name1 in d.keys():
for name2 in d[name1].keys():
if float( d[name1][name2] ) < lowestPair[2]:
lowestPair = [name1, name2, d[name1][name2]]
averageList = []
for name in lowestPair[0:2]:
for otherName in d[name].keys():
if otherName not in lowestPair:
average = (float( d[lowestPair[0]][otherName] ) + float( d[lowestPair[1]][otherName] ))/2
d[name][otherName] = average
averageList.append(average)
print( averageList )
可以这样访问