MCPcopy Create free account
hub / github.com/angular/components / addChild

Method addChild

src/cdk/tree/tree.spec.ts:1590–1607  ·  view source on GitHub ↗
(parent: TestData, isFlat: boolean = true)

Source from the content-addressed store, hash-verified

1588 }
1589
1590 addChild(parent: TestData, isFlat: boolean = true) {
1591 const nextIndex = ++this.dataIndex;
1592 const child = new TestData(
1593 `topping_${nextIndex}`,
1594 `cheese_${nextIndex}`,
1595 `base_${nextIndex}`,
1596 parent.level + 1,
1597 );
1598 parent.children.push(child);
1599 if (isFlat) {
1600 let copiedData = this.data.slice();
1601 copiedData.splice(this.data.indexOf(parent) + 1, 0, child);
1602 this.data = copiedData;
1603 } else {
1604 parent.observableChildren.next(parent.children);
1605 }
1606 return child;
1607 }
1608
1609 addData(level: number = 1): TestData {
1610 const nextIndex = ++this.dataIndex;

Callers 4

constructorMethod · 0.95
tree.spec.tsFile · 0.45
mutateChildrenFunction · 0.45

Calls 2

pushMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected