In my C# web API, I have defined an enum with a specified display name:
public enum Countries
{
Australia,
[Display(Name="New Zealand")] NewZealand
}
I send this list as a list of strings to my Angular project to display it in a dropdown menu, but I still got "NewZealand" displayed. How can I send the right data to my Angular Project without having to create a new list or enum list in Angular (to avoid duplicate data and thus problems when values would change)?
I also tried with the following code with the same outcome:
public enum Countries
{
Australia,
[Description("New Zealand")] NewZealand
}
EDIT: here's the code that converts my enums to a list of string:
public List<string> GetAllCountries()
{
var listOfAllCountries = new List<string>();
foreach (var country in Enum.GetValues(typeof(Countries)))
{
listOfAllCountries.Add(country.ToString());
}
return listOfAllCountries ;
}