Angular - Get parent component receive data after init@Directive v/s @Component in AngularAngular 2: getting RouteParams from parent componentAngular - Use pipes in services and componentsAngular dynamic tabs with user-click chosen components(Routable Component) Data tree with adjacent detail paneAngular - What is the meanings of module.id in component?Angular 2 click event causing entire component to re-initialize (losing state)Angular 4: How to use same component as both parent and child?How to select all the nodes on prime angular p-tree?Trying to receive file from mat-dialog angular in parent component

GFCI Outlet in Bathroom, Lights not working

Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?

Can an old DSLR be upgraded to match modern smartphone image quality

How to provide realism without making readers think grimdark

Is there a rule that prohibits us from using 2 possessives in a row?

Initialize an array of doubles at compile time

Do adult Russians normally hand-write Cyrillic as cursive or as block letters?

How can a single Member of the House block a Congressional bill?

You've spoiled/damaged the card

NTP rollover-safe design with ESP8266 (Curiosity)

Why don't B747s start takeoffs with full throttle?

What's the most polite way to tell a manager "shut up and let me work"?

Opposite of "Squeaky wheel gets the grease"

Could a guilty Boris Johnson be used to cancel Brexit?

How can Iron Man's suit withstand this?

Applicants clearly not having the skills they advertise

Unorthodox way of solving Einstein field equations

What is the right way to float a home lab?

Does Peach's float negate shorthop knockback multipliers?

When leasing/renting out an owned property, is there a standard ratio between monthly rent and the mortgage?

Accidentally cashed a check twice

Why is Colorado so different politically from nearby states?

Anyone teach web development? How do you assess it?

Can you please explain this joke: "I'm going bananas is what I tell my bananas before I leave the house"?



Angular - Get parent component receive data after init


@Directive v/s @Component in AngularAngular 2: getting RouteParams from parent componentAngular - Use pipes in services and componentsAngular dynamic tabs with user-click chosen components(Routable Component) Data tree with adjacent detail paneAngular - What is the meanings of module.id in component?Angular 2 click event causing entire component to re-initialize (losing state)Angular 4: How to use same component as both parent and child?How to select all the nodes on prime angular p-tree?Trying to receive file from mat-dialog angular in parent component






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have Angular front end which fetches data from Lumen backend:



ngAfterViewInit() 

merge()
.pipe(
startWith(),
switchMap(() =>
this.isLoadingResults = true;
return this.exampleDatabase!.getRepoIssues(this.itemId);
),
map(data =>
this.isLoadingResults = false;
this.isRateLimitReached = false;

return data;
),
catchError(() =>
this.isLoadingResults = false;
this.isRateLimitReached = true;
return observableOf([]);
)
).subscribe(
data => this.applyDataChanges(data)
);


private applyDataChanges(data: any)
let tree = [];

for(let b of data.buildings)
let children = [];
for(let c of b.buildings)
children.push(new ChecklistNodeModel(c.name, false))

tree.push(new ChecklistNodeModel(b.group.name, false, children));


this.TREE_DATA = tree;

this.itemId > 0 ?
this.form = data as ControllingCompanyNewsModel :
this.form = new ControllingCompanyNewsModel(0,null,'','','', data.buildings);



Parent component has following property which then passes through @Input binding to child component:



 <app-checklist-tree [treeData]="TREE_DATA"></app-checklist-tree>


and



 @Input() treeData = [];


The question is for sone reason the child component has empty treeData property. While parent component has property updated correctly.



Could anyone advice where I made a mistake?
Thank you!



Adding child component code



export class ChecklistTreeComponent implements AfterViewInit, OnChanges 

@Input() treeData = [];
@Output() treeDataChange = new EventEmitter<ChecklistNodeModel[]>();
levels = new Map<ChecklistNodeModel, number>();
treeControl: FlatTreeControl<ChecklistNodeModel>;

treeFlattener: MatTreeFlattener<ChecklistNodeModel, ChecklistNodeModel>;

dataSource: MatTreeFlatDataSource<ChecklistNodeModel, ChecklistNodeModel>;

constructor(private changeDetectorRef: ChangeDetectorRef)
this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren);
this.treeControl = new FlatTreeControl<ChecklistNodeModel>(
this.getLevel, this.isExpandable);
this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
// this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
this.dataSource.data = this.treeData;




getLevel = (node: ChecklistNodeModel): number => 0;
;

isExpandable = (node: ChecklistNodeModel): boolean =>
return node.children.value.length > 0;
;

getChildren = (node: ChecklistNodeModel) =>
return node.children;
;

transformer = (node: ChecklistNodeModel, level: number) =>
this.levels.set(node, level);
return node;


hasChildren = (index: number, node: ChecklistNodeModel) =>
return this.isExpandable(node);


/** The selection for checklist */
checklistSelection = new SelectionModel<ChecklistNodeModel>(true /* multiple */);

/** Whether all the descendants of the node are selected */
descendantsAllSelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return this.checklistSelection.isSelected(node);

const selected = this.checklistSelection.isSelected(node);
const allSelected = descendants.every(child => this.checklistSelection.isSelected(child));
if (!selected && allSelected)
this.checklistSelection.select(node);
this.changeDetectorRef.markForCheck();

return allSelected;


/** Whether part of the descendants are selected */
descendantsPartiallySelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return false;

const result = descendants.some(child => this.checklistSelection.isSelected(child));
return result && !this.descendantsAllSelected(node);


/** Toggle the selection. Select/deselect all the descendants node */
nodeSelectionToggle(node: ChecklistNodeModel): void
node.checked = !node.checked;
this.checklistSelection.toggle(node);
const descendants = this.treeControl.getDescendants(node);
if(this.checklistSelection.isSelected(node))
this.checklistSelection.select(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);

else
this.checklistSelection.deselect(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);


this.changeDetectorRef.markForCheck();


ngAfterViewInit(): void
this.dataSource.data = this.treeData;


ngOnChanges(changes: SimpleChanges): void
this.dataSource.data = changes.treeData.currentValue;













share|improve this question



















  • 1





    Can you add the code of the child component ?

    – Ranika Nisal
    Mar 24 at 12:42











  • @RanikaNisal yes. please check

    – Aleksandr Popov
    Mar 24 at 12:44











  • So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

    – Ethan Melamed
    Mar 24 at 12:51











  • Do you get a simpleChanges object when you run the web app?

    – Ranika Nisal
    Mar 24 at 12:55











  • @EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

    – Aleksandr Popov
    Mar 24 at 12:57

















0















I have Angular front end which fetches data from Lumen backend:



ngAfterViewInit() 

merge()
.pipe(
startWith(),
switchMap(() =>
this.isLoadingResults = true;
return this.exampleDatabase!.getRepoIssues(this.itemId);
),
map(data =>
this.isLoadingResults = false;
this.isRateLimitReached = false;

return data;
),
catchError(() =>
this.isLoadingResults = false;
this.isRateLimitReached = true;
return observableOf([]);
)
).subscribe(
data => this.applyDataChanges(data)
);


private applyDataChanges(data: any)
let tree = [];

for(let b of data.buildings)
let children = [];
for(let c of b.buildings)
children.push(new ChecklistNodeModel(c.name, false))

tree.push(new ChecklistNodeModel(b.group.name, false, children));


this.TREE_DATA = tree;

this.itemId > 0 ?
this.form = data as ControllingCompanyNewsModel :
this.form = new ControllingCompanyNewsModel(0,null,'','','', data.buildings);



Parent component has following property which then passes through @Input binding to child component:



 <app-checklist-tree [treeData]="TREE_DATA"></app-checklist-tree>


and



 @Input() treeData = [];


The question is for sone reason the child component has empty treeData property. While parent component has property updated correctly.



Could anyone advice where I made a mistake?
Thank you!



Adding child component code



export class ChecklistTreeComponent implements AfterViewInit, OnChanges 

@Input() treeData = [];
@Output() treeDataChange = new EventEmitter<ChecklistNodeModel[]>();
levels = new Map<ChecklistNodeModel, number>();
treeControl: FlatTreeControl<ChecklistNodeModel>;

treeFlattener: MatTreeFlattener<ChecklistNodeModel, ChecklistNodeModel>;

dataSource: MatTreeFlatDataSource<ChecklistNodeModel, ChecklistNodeModel>;

constructor(private changeDetectorRef: ChangeDetectorRef)
this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren);
this.treeControl = new FlatTreeControl<ChecklistNodeModel>(
this.getLevel, this.isExpandable);
this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
// this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
this.dataSource.data = this.treeData;




getLevel = (node: ChecklistNodeModel): number => 0;
;

isExpandable = (node: ChecklistNodeModel): boolean =>
return node.children.value.length > 0;
;

getChildren = (node: ChecklistNodeModel) =>
return node.children;
;

transformer = (node: ChecklistNodeModel, level: number) =>
this.levels.set(node, level);
return node;


hasChildren = (index: number, node: ChecklistNodeModel) =>
return this.isExpandable(node);


/** The selection for checklist */
checklistSelection = new SelectionModel<ChecklistNodeModel>(true /* multiple */);

/** Whether all the descendants of the node are selected */
descendantsAllSelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return this.checklistSelection.isSelected(node);

const selected = this.checklistSelection.isSelected(node);
const allSelected = descendants.every(child => this.checklistSelection.isSelected(child));
if (!selected && allSelected)
this.checklistSelection.select(node);
this.changeDetectorRef.markForCheck();

return allSelected;


/** Whether part of the descendants are selected */
descendantsPartiallySelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return false;

const result = descendants.some(child => this.checklistSelection.isSelected(child));
return result && !this.descendantsAllSelected(node);


/** Toggle the selection. Select/deselect all the descendants node */
nodeSelectionToggle(node: ChecklistNodeModel): void
node.checked = !node.checked;
this.checklistSelection.toggle(node);
const descendants = this.treeControl.getDescendants(node);
if(this.checklistSelection.isSelected(node))
this.checklistSelection.select(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);

else
this.checklistSelection.deselect(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);


this.changeDetectorRef.markForCheck();


ngAfterViewInit(): void
this.dataSource.data = this.treeData;


ngOnChanges(changes: SimpleChanges): void
this.dataSource.data = changes.treeData.currentValue;













share|improve this question



















  • 1





    Can you add the code of the child component ?

    – Ranika Nisal
    Mar 24 at 12:42











  • @RanikaNisal yes. please check

    – Aleksandr Popov
    Mar 24 at 12:44











  • So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

    – Ethan Melamed
    Mar 24 at 12:51











  • Do you get a simpleChanges object when you run the web app?

    – Ranika Nisal
    Mar 24 at 12:55











  • @EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

    – Aleksandr Popov
    Mar 24 at 12:57













0












0








0








I have Angular front end which fetches data from Lumen backend:



ngAfterViewInit() 

merge()
.pipe(
startWith(),
switchMap(() =>
this.isLoadingResults = true;
return this.exampleDatabase!.getRepoIssues(this.itemId);
),
map(data =>
this.isLoadingResults = false;
this.isRateLimitReached = false;

return data;
),
catchError(() =>
this.isLoadingResults = false;
this.isRateLimitReached = true;
return observableOf([]);
)
).subscribe(
data => this.applyDataChanges(data)
);


private applyDataChanges(data: any)
let tree = [];

for(let b of data.buildings)
let children = [];
for(let c of b.buildings)
children.push(new ChecklistNodeModel(c.name, false))

tree.push(new ChecklistNodeModel(b.group.name, false, children));


this.TREE_DATA = tree;

this.itemId > 0 ?
this.form = data as ControllingCompanyNewsModel :
this.form = new ControllingCompanyNewsModel(0,null,'','','', data.buildings);



Parent component has following property which then passes through @Input binding to child component:



 <app-checklist-tree [treeData]="TREE_DATA"></app-checklist-tree>


and



 @Input() treeData = [];


The question is for sone reason the child component has empty treeData property. While parent component has property updated correctly.



Could anyone advice where I made a mistake?
Thank you!



Adding child component code



export class ChecklistTreeComponent implements AfterViewInit, OnChanges 

@Input() treeData = [];
@Output() treeDataChange = new EventEmitter<ChecklistNodeModel[]>();
levels = new Map<ChecklistNodeModel, number>();
treeControl: FlatTreeControl<ChecklistNodeModel>;

treeFlattener: MatTreeFlattener<ChecklistNodeModel, ChecklistNodeModel>;

dataSource: MatTreeFlatDataSource<ChecklistNodeModel, ChecklistNodeModel>;

constructor(private changeDetectorRef: ChangeDetectorRef)
this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren);
this.treeControl = new FlatTreeControl<ChecklistNodeModel>(
this.getLevel, this.isExpandable);
this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
// this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
this.dataSource.data = this.treeData;




getLevel = (node: ChecklistNodeModel): number => 0;
;

isExpandable = (node: ChecklistNodeModel): boolean =>
return node.children.value.length > 0;
;

getChildren = (node: ChecklistNodeModel) =>
return node.children;
;

transformer = (node: ChecklistNodeModel, level: number) =>
this.levels.set(node, level);
return node;


hasChildren = (index: number, node: ChecklistNodeModel) =>
return this.isExpandable(node);


/** The selection for checklist */
checklistSelection = new SelectionModel<ChecklistNodeModel>(true /* multiple */);

/** Whether all the descendants of the node are selected */
descendantsAllSelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return this.checklistSelection.isSelected(node);

const selected = this.checklistSelection.isSelected(node);
const allSelected = descendants.every(child => this.checklistSelection.isSelected(child));
if (!selected && allSelected)
this.checklistSelection.select(node);
this.changeDetectorRef.markForCheck();

return allSelected;


/** Whether part of the descendants are selected */
descendantsPartiallySelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return false;

const result = descendants.some(child => this.checklistSelection.isSelected(child));
return result && !this.descendantsAllSelected(node);


/** Toggle the selection. Select/deselect all the descendants node */
nodeSelectionToggle(node: ChecklistNodeModel): void
node.checked = !node.checked;
this.checklistSelection.toggle(node);
const descendants = this.treeControl.getDescendants(node);
if(this.checklistSelection.isSelected(node))
this.checklistSelection.select(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);

else
this.checklistSelection.deselect(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);


this.changeDetectorRef.markForCheck();


ngAfterViewInit(): void
this.dataSource.data = this.treeData;


ngOnChanges(changes: SimpleChanges): void
this.dataSource.data = changes.treeData.currentValue;













share|improve this question
















I have Angular front end which fetches data from Lumen backend:



ngAfterViewInit() 

merge()
.pipe(
startWith(),
switchMap(() =>
this.isLoadingResults = true;
return this.exampleDatabase!.getRepoIssues(this.itemId);
),
map(data =>
this.isLoadingResults = false;
this.isRateLimitReached = false;

return data;
),
catchError(() =>
this.isLoadingResults = false;
this.isRateLimitReached = true;
return observableOf([]);
)
).subscribe(
data => this.applyDataChanges(data)
);


private applyDataChanges(data: any)
let tree = [];

for(let b of data.buildings)
let children = [];
for(let c of b.buildings)
children.push(new ChecklistNodeModel(c.name, false))

tree.push(new ChecklistNodeModel(b.group.name, false, children));


this.TREE_DATA = tree;

this.itemId > 0 ?
this.form = data as ControllingCompanyNewsModel :
this.form = new ControllingCompanyNewsModel(0,null,'','','', data.buildings);



Parent component has following property which then passes through @Input binding to child component:



 <app-checklist-tree [treeData]="TREE_DATA"></app-checklist-tree>


and



 @Input() treeData = [];


The question is for sone reason the child component has empty treeData property. While parent component has property updated correctly.



Could anyone advice where I made a mistake?
Thank you!



Adding child component code



export class ChecklistTreeComponent implements AfterViewInit, OnChanges 

@Input() treeData = [];
@Output() treeDataChange = new EventEmitter<ChecklistNodeModel[]>();
levels = new Map<ChecklistNodeModel, number>();
treeControl: FlatTreeControl<ChecklistNodeModel>;

treeFlattener: MatTreeFlattener<ChecklistNodeModel, ChecklistNodeModel>;

dataSource: MatTreeFlatDataSource<ChecklistNodeModel, ChecklistNodeModel>;

constructor(private changeDetectorRef: ChangeDetectorRef)
this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren);
this.treeControl = new FlatTreeControl<ChecklistNodeModel>(
this.getLevel, this.isExpandable);
this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
// this.dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
this.dataSource.data = this.treeData;




getLevel = (node: ChecklistNodeModel): number => 0;
;

isExpandable = (node: ChecklistNodeModel): boolean =>
return node.children.value.length > 0;
;

getChildren = (node: ChecklistNodeModel) =>
return node.children;
;

transformer = (node: ChecklistNodeModel, level: number) =>
this.levels.set(node, level);
return node;


hasChildren = (index: number, node: ChecklistNodeModel) =>
return this.isExpandable(node);


/** The selection for checklist */
checklistSelection = new SelectionModel<ChecklistNodeModel>(true /* multiple */);

/** Whether all the descendants of the node are selected */
descendantsAllSelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return this.checklistSelection.isSelected(node);

const selected = this.checklistSelection.isSelected(node);
const allSelected = descendants.every(child => this.checklistSelection.isSelected(child));
if (!selected && allSelected)
this.checklistSelection.select(node);
this.changeDetectorRef.markForCheck();

return allSelected;


/** Whether part of the descendants are selected */
descendantsPartiallySelected(node: ChecklistNodeModel): boolean
const descendants = this.treeControl.getDescendants(node);
if (!descendants.length)
return false;

const result = descendants.some(child => this.checklistSelection.isSelected(child));
return result && !this.descendantsAllSelected(node);


/** Toggle the selection. Select/deselect all the descendants node */
nodeSelectionToggle(node: ChecklistNodeModel): void
node.checked = !node.checked;
this.checklistSelection.toggle(node);
const descendants = this.treeControl.getDescendants(node);
if(this.checklistSelection.isSelected(node))
this.checklistSelection.select(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);

else
this.checklistSelection.deselect(...descendants, node);
for(let descendant of descendants)
this.nodeSelectionToggle(descendant);


this.changeDetectorRef.markForCheck();


ngAfterViewInit(): void
this.dataSource.data = this.treeData;


ngOnChanges(changes: SimpleChanges): void
this.dataSource.data = changes.treeData.currentValue;










angular angular-material






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 13:46









Vadorequest

5,7721064138




5,7721064138










asked Mar 24 at 12:29









Aleksandr PopovAleksandr Popov

12611




12611







  • 1





    Can you add the code of the child component ?

    – Ranika Nisal
    Mar 24 at 12:42











  • @RanikaNisal yes. please check

    – Aleksandr Popov
    Mar 24 at 12:44











  • So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

    – Ethan Melamed
    Mar 24 at 12:51











  • Do you get a simpleChanges object when you run the web app?

    – Ranika Nisal
    Mar 24 at 12:55











  • @EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

    – Aleksandr Popov
    Mar 24 at 12:57












  • 1





    Can you add the code of the child component ?

    – Ranika Nisal
    Mar 24 at 12:42











  • @RanikaNisal yes. please check

    – Aleksandr Popov
    Mar 24 at 12:44











  • So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

    – Ethan Melamed
    Mar 24 at 12:51











  • Do you get a simpleChanges object when you run the web app?

    – Ranika Nisal
    Mar 24 at 12:55











  • @EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

    – Aleksandr Popov
    Mar 24 at 12:57







1




1





Can you add the code of the child component ?

– Ranika Nisal
Mar 24 at 12:42





Can you add the code of the child component ?

– Ranika Nisal
Mar 24 at 12:42













@RanikaNisal yes. please check

– Aleksandr Popov
Mar 24 at 12:44





@RanikaNisal yes. please check

– Aleksandr Popov
Mar 24 at 12:44













So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

– Ethan Melamed
Mar 24 at 12:51





So two questions: (1) Is the code that sets TREE_DATA in the parent being reached? (2) Have you tried putting ‘ngOnChanges(changes) console.log(changes) ’ or something similar in the child?

– Ethan Melamed
Mar 24 at 12:51













Do you get a simpleChanges object when you run the web app?

– Ranika Nisal
Mar 24 at 12:55





Do you get a simpleChanges object when you run the web app?

– Ranika Nisal
Mar 24 at 12:55













@EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

– Aleksandr Popov
Mar 24 at 12:57





@EthanMelamed thanks for your responce. (1) yes it does updates TREE_DATA in parent as far as I can see from Augury. (2) nothing being outputed into logs

– Aleksandr Popov
Mar 24 at 12:57












1 Answer
1






active

oldest

votes


















1














Implement this in the parent component



//import CheckListTreeComponent
//Import viewChild from angular core
export class ParentClass
@ViewChild(ChecklistTreeComponent)
private tree : ChecklistTreeComponent;

constructor()
//



At the point you are sure that the parent component has received it's value



this.tree.update(this.TREE_DATA)


In the child component



update(value)
this.treeData = value;






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323808%2fangular-get-parent-component-receive-data-after-init%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Implement this in the parent component



    //import CheckListTreeComponent
    //Import viewChild from angular core
    export class ParentClass
    @ViewChild(ChecklistTreeComponent)
    private tree : ChecklistTreeComponent;

    constructor()
    //



    At the point you are sure that the parent component has received it's value



    this.tree.update(this.TREE_DATA)


    In the child component



    update(value)
    this.treeData = value;






    share|improve this answer



























      1














      Implement this in the parent component



      //import CheckListTreeComponent
      //Import viewChild from angular core
      export class ParentClass
      @ViewChild(ChecklistTreeComponent)
      private tree : ChecklistTreeComponent;

      constructor()
      //



      At the point you are sure that the parent component has received it's value



      this.tree.update(this.TREE_DATA)


      In the child component



      update(value)
      this.treeData = value;






      share|improve this answer

























        1












        1








        1







        Implement this in the parent component



        //import CheckListTreeComponent
        //Import viewChild from angular core
        export class ParentClass
        @ViewChild(ChecklistTreeComponent)
        private tree : ChecklistTreeComponent;

        constructor()
        //



        At the point you are sure that the parent component has received it's value



        this.tree.update(this.TREE_DATA)


        In the child component



        update(value)
        this.treeData = value;






        share|improve this answer













        Implement this in the parent component



        //import CheckListTreeComponent
        //Import viewChild from angular core
        export class ParentClass
        @ViewChild(ChecklistTreeComponent)
        private tree : ChecklistTreeComponent;

        constructor()
        //



        At the point you are sure that the parent component has received it's value



        this.tree.update(this.TREE_DATA)


        In the child component



        update(value)
        this.treeData = value;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 13:44









        Ranika NisalRanika Nisal

        32829




        32829





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323808%2fangular-get-parent-component-receive-data-after-init%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현