MCPcopy Index your code
hub / github.com/angular/components / addChild

Method addChild

src/material/tree/tree.spec.ts:713–736  ·  view source on GitHub ↗
(parent: TestData, isSpecial: boolean = false)

Source from the content-addressed store, hash-verified

711 }
712
713 addChild(parent: TestData, isSpecial: boolean = false) {
714 const nextIndex = ++this.dataIndex;
715 const child = new TestData(`topping_${nextIndex}`, `cheese_${nextIndex}`, `base_${nextIndex}`);
716
717 const index = this.data.indexOf(parent);
718 if (index > -1) {
719 parent = new TestData(
720 parent.pizzaTopping,
721 parent.pizzaCheese,
722 parent.pizzaBase,
723 parent.children,
724 isSpecial,
725 );
726 }
727 parent.children.push(child);
728 parent.observableChildren.next(parent.children);
729
730 let copiedData = this.data.slice();
731 if (index > -1) {
732 copiedData.splice(index, 1, parent);
733 }
734 this.data = copiedData;
735 return child;
736 }
737
738 addData(isSpecial: boolean = false) {
739 const nextIndex = ++this.dataIndex;

Callers 1

tree.spec.tsFile · 0.45

Calls 2

pushMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected