//In your ViewComponent C# file make sure you pass in a parameter of the type of Model you are expecting to be passed to the ViewComponent Default CSHTML file. For example
public async Task<IViewComponentResult> InvokeAsync(TypeOfClass object)
{
return View(object);
}
//Then from the Razor Page at the Front-End, invoke the ViewComponent and pass the object of type as shown above
<div class="container-fluid col-lg-8 col-md-8">
@await Component.InvokeAsync("TypeOfClass", new NameSpace.FolderOfYourModels.TypeOfClass{ PropertyName=Model.FirstOrDefault().PropertyName,
PropertyName=Model.FirstOrDefault().PropertyName})
</div>?
LOL
sxsq said:
ddw