How to display data in child component when passed from parent component in Blazor?

168 views Asked by At

This is my School Class.

public class School{

public List<Students> Student{get;set;}

public School(){
Student = new List<Students>();
}

}

public class Student{
public string Name {get;set;}
}

I created a new object of this class in the parent Razor component and sending a List of Students.

@page"/parent"
<Child Data="@s.Student"/>

@code{
public School s = new School(); 
 protected override async Task OnInitializedAsync(){
s  = await getSchoolStudents("api");
}

This is Child Component. Data is not coming from parent to child. And I want to send the data further in js interops.

 @page"/child"
@typeparameter T

@code{
[Parameter]
public List<T> Data{get;set;}
}
0

There are 0 answers