This code will help you to understand how to use the invoke method on a parameter value change.
The better solution is to invoke the method in the set value of the parameter.
@code { string _myString; [Parameter] public string MyString { get {return _myString; } set { _myString = value; this.ValueChange(); } } private void ValueChange() { Console.WriteLine("Parameter value has changed"); } }
You can also override the OnParameterSet or OnParameterSetAsync lifecycle methods. Those methods are triggered every time any parameter value changes.
@code { [Parameter] protected string MyString {get;set;} protected override void OnParametersSet() { this.ValueChange(); } private void ValueChange() { Console.WriteLine("Parameter value has changed"); } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
The better solution is to invoke the method in the set value of the parameter.
You can also override the OnParameterSet or OnParameterSetAsync lifecycle methods. Those methods are triggered every time any parameter value changes.
need an explanation for this answer? contact us directly to get an explanation for this answer