2

Is it equivalent of event emit like the underneath in blazor ? : https://angular.io/api/core/EventEmitter (in angular) https://v2.vuejs.org/v2/guide/components-custom-events.html (in vue)

in new blazor syntax @ event name in < > of component (3.0 preview 6)

5
  • Ta question est incompréhensible et ne respecte pas How to Ask : profite que je parle français, explique moi rapidement ton souci que je t'aide ! Commented Jun 19, 2019 at 13:40
  • Désolé c'est mon premier message je ne savais pas trop dans quel rubrique le poster Commented Jun 19, 2019 at 14:09
  • Existe il un equivalent de la fonction event emit (qui est dans angular et vue) pour blazor Commented Jun 19, 2019 at 14:09
  • si il y en a un je pense que il faudrait taper @ quelque chose dans la baliste < > merci Commented Jun 19, 2019 at 14:10
  • ça devrait t'aider : github.com/aspnet/Blazor/issues/1355 Commented Jun 19, 2019 at 14:24

1 Answer 1

3

This work :

Index.razor

<SurveyPrompt Title="How is Blazor working for you?" Counter="@Counter" CounterChanged="@CounterChangedFiredEvent" />

<p>Counter: @Counter</p>

@code {
    private int Counter = 1;

    void CounterChangedFiredEvent(int counter)
    {
        Counter = counter;
        StateHasChanged();
    }
}

SuveyPrompt.razor

<input type="button" value="Previuos" @onclick="@Previous" />
<input type="button" value="Next" @onclick="@Next" />

@code {
    // Demonstrates how a parent component can supply parameters
    [Parameter] string Title { get; set; }

    [Parameter]
    private int Counter { get; set; }

    [Parameter]
    Action<int> CounterChanged { get; set; }

    void Next()
    {
        CounterChanged(++Counter);
    }

    void Previous()
    {
        CounterChanged(--Counter);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.