New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make child component to be rendered in parent component? #1782

Closed
thainbreese opened this Issue Feb 6, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@thainbreese
Copy link

thainbreese commented Feb 6, 2019

Both of the parent and child component use the same int array object.

If I change the array in the parent component, the child component has to be rendered again.

How can I do this?

I was tried to bind the object to child component, however it said that cannot bind array object.

@danroth27

This comment has been minimized.

Copy link
Member

danroth27 commented Feb 6, 2019

This issue was moved to aspnet/AspNetCore#7328

@iAmBipinPaul

This comment has been minimized.

Copy link

iAmBipinPaul commented Feb 6, 2019

I believe you want to pass the array to child component and render it there.

child component (child.cshtml)

@if(TTypeNames ==null)
{
// some html to say it's loading 
}else if(TTypeNames.Count ==0)
{
//  // some html to say it's empty
}
else 
{
foreach(var item in TTypeNames )
{
// html
}
}

@functions {   
    [Parameter] List<TType> TTypeNames { get; set; }
    protected override async Task OnParametersSetAsync()
    {
       StateHasChanged();
    }
}

now in your parent component you can pass data like this

<child TTypeNames ="@TTypeList"></child>

better to go through this blazor workshop it explains everything in awesome way.
https://aka.ms/blazorworkshop

documentation showing list of orders
https://github.com/dotnet-presentations/blazor-workshop/blob/master/docs/03-show-order-status.md#displaying-the-list-of-orders

@aspnet aspnet locked and limited conversation to collaborators Feb 6, 2019

@danroth27 danroth27 closed this Feb 6, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.