MCPcopy
hub / github.com/angular/components / addChild

Method addChild

src/cdk/tree/tree-with-tree-control.spec.ts:1316–1333  ·  view source on GitHub ↗
(parent: TestData, isFlat: boolean = true)

Source from the content-addressed store, hash-verified

1314 }
1315
1316 addChild(parent: TestData, isFlat: boolean = true) {
1317 const nextIndex = ++this.dataIndex;
1318 const child = new TestData(
1319 `topping_${nextIndex}`,
1320 `cheese_${nextIndex}`,
1321 `base_${nextIndex}`,
1322 parent.level + 1,
1323 );
1324 parent.children.push(child);
1325 if (isFlat) {
1326 let copiedData = this.data.slice();
1327 copiedData.splice(this.data.indexOf(parent) + 1, 0, child);
1328 this.data = copiedData;
1329 } else {
1330 parent.observableChildren.next(parent.children);
1331 }
1332 return child;
1333 }
1334
1335 addData(level: number = 1) {
1336 const nextIndex = ++this.dataIndex;

Callers 4

constructorMethod · 0.95
mutateChildrenFunction · 0.45

Calls 2

pushMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected