Q:

Angular2/Typescript - property name first letter changes from lower to upper case

I'm a noob in Angular2/Typescript and I'm writing my first application.
I have an array of this simple class:
Class
export class OffertRegion {
    
    public idOffert: number;
    public idOffertRegion: number;
    public Region: string;
    public intOrder: number;
    
    constructor(values: Object = {}) {
        Object.assign(this, values);
    }
}

And this is the function that push a new OffertRegion class to the array once the user click on a button placed in the html component page:
do_addRegion()
  {
    var r = new OffertRegion();
    r.Region = this.FormOffertDetail.value.RegionName;
    alert(r.Region);
    r.idOffert = this.offert.idOffert;

    this.offert.Regions.push(r);
    console.log(this.offert.Regions);
  }

If I load an example with 3 regions and I execute the do_addRegion(), the logged this.offert.Regions result is this:
Console.Log output

As you can see, the previews items of class OffertRegion has the property Region with the first character in lower case.
Instead the new item (position 4) has the property with the first character in uppercase...
This cause me some troubles when I work to render the data in the html template.
Why is this happening? And how to fix it in the right way?
Thanks

A:

I can only guess from the sparse information you provide. I assume that the first three objects are loaded from a server, which uses names starting with lowercase letters. They somehow make it into the array without conforming to the Typescript type. Then you run do_addRegion, which creates an instance with only two properties, one of them with a name that starts with an uppercase letter.
Your Typescript type is slightly odd: It has three properties whose name starts with a lowercase letter and the odd property named Region. It would be more consistent to name it with a lowercase name:
    public region: string;

To dig deeper into the problem, you should show the code that loads or creates the first three entries in your array.

