For example, in c#, we have this snippet:
class OrderLine
{
public OrderLine(){
OrderId ="1",
ItemTitle ="2"
Console.WriteLine("constructing");
}
public string Platform { get; set; }
public string OrderId { get; set; }
public string ItemTitle { get; set; }
}
public static void Main()
{
var ol = new OrderLine
{
Platform ="p"
};
Console.WriteLine(ol.Platform);
}
In Typescript, if I use {} to initialize an object, I won't be able to call the constrcuor which can give me some default value and do something else. if I use new key word to do some default construction, my compiler doesn't allow me to use object initializer(I am using angular 6), and I have to call ol.Platform to assign property value. When I have several properties to set value, writing multiple "ol." is not as fast as to use the object initializer syntax. is there a better way?