Skip to content
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 can I pass a parameter to a component that inherits ViewComponentBase #5

Open
omarwasfi opened this issue Nov 21, 2022 · 0 comments

Comments

@omarwasfi
Copy link

omarwasfi commented Nov 21, 2022

I have a Tasks Page that should display tasks.
I want to separate each task and display each one in a component

This is Blazor component representing a task row

@inherits ViewComponentBase

<h6>@TaskModel.Oid</h6>

@code {

[Parameter]
public TaskModel TaskModel { get; set; }

}

public class TaskRowComponentController : ControllerComponentBase<TaskRowComponent>
{

}

The tasks page

@inherits ViewComponentBase

@foreach (TaskModel task in Tasks)
{

}

@code {

public List<TaskModel> Tasks { get; set; } = new List<TaskModel>();

}

using Palermo.BlazorMvc;

namespace App.MauiBrazor.Pages.TaskPages
{
[Route("/Tasks")]
public class TasksPageController : ControllerComponentBase
{
private RestClient _restClient = new RestClient();

    private List<TaskModel> tasks { get; set; }

    protected override async Task OnInitializedAsync()
    {

        tasks = await _restClient.CTTasks();
        
        if(tasks != null)
        {
            View.Tasks = this.tasks;
            StateHasChanged();

        }
        

    }

}

}

This approach doesn't work.. What should I do ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant