源代码:
export class CmsService {
private components: {
[uid: string]: {
[pageContext: string]: Observable<CmsComponent>;
};
} = {};
用下面这个简化版的例子来学习:
interface Jerry {
[uid: string]: {
[pageContext: string]: Observable<number[]>;
};
}
如何给这个复合结构赋值:
let testdata: Jerry = {};
testdata.uid1 = {};
const bulk1 = {
contentPage: of([1, 2, 3])
};
const bulk2 = {
footerPage: of([4, 5, 6])
};
const bulk3 = {
HeaderPage: of([7, 8, 9])
};
testdata.uid1 = { ...bulk1, ... bulk2};
testdata.uid2 = bulk3 ;
// how to copy bulk3 of uid2 to uid1??
testdata.uid1.HeaderPage = bulk3.HeaderPage;
Object.assign(testdata.uid2, bulk1)
console.log('data: ' + testdata);
结果: