I'm working with Angular and Typescript and I'm wondering how come that if I add a value of string for example "hahah" to a field which should accept numbers only and it's binded to property of type number also wont fire or trigger any error, insted of that value of that field will be zero! I mean that is fine for me, it's better to result as a zero than to result as a some strange value, but I'm just curious how is that?
Here is how my typescript class looks:
export class Article {
public id: string;
public price: number;
public price2: number;
}
Here is my template .html file:
<div class="form-group">
<label class="control-label dash-control-label col-sm-3" for="">Price:</label>
<div class="col-sm-3">
<input type="text" class="form-control dash-form-control" id="" placeholder="" name="price" [(ngModel)]="article.price">
</div>
<label class="control-label dash-control-label col-sm-3" for="">Price 2:</label>
<div class="col-sm-3">
<input type="text" class="form-control dash-form-control" id="" placeholder="" name="price2" [(ngModel)]="article.price2">
</div>
</div>
As you can see guys inputs are binded to [(ngModel)]="article.price" and to
[(ngModel)]="article.price2" and they looks like this when app is runned:
But everything is fine if I type something like this:
And when I do post, In my database is stored value : ZERO (0) !
How come?
Why there is no error like I'm trying to add a string to a number or whatever?
Thanks

