1

I have an angular 2 form that uses a PODO to store model values in.

It has a set of properties that accept integer values.

When i inspect that response that is posted to the web server, these values are coming back as floating point values.

Question: Why is my integer accepts floating point assignments?

enter image description here

<div class="form-group">
  <label for="card_number">Credit Card Number</label>
  <input type="number" id="card_number" [(ng-model)]="dto.ccn" class="form-control" [required]="true"/>
</div>

<div class="form-group">
  <label for="card_expiration">Expiration</label>
  <input type="text" id="card_expiration" [(ng-model)]="dto.ccExpiration" class="form-control" [required]="true"/>
</div>

<div class="form-group">
  <label for="card_ccv">CCV</label>
  <input type="number" id="card_ccv" [(ng-model)]="dto.ccv" class="form-control" [required]="true"/>
</div>
Jack Murphy
  • 2,952
  • 1
  • 30
  • 49

1 Answers1

0

JS doesn't distinguish between double/float and int and so can't Dart when compiled to JS.

See also https://www.dartlang.org/articles/numeric-computation/#considerations-when-dart-is-compiled-to-javascript

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • is there a way to limit values to integers? This breaks serialization on the server side. – Jack Murphy Nov 01 '15 at 20:45
  • Doesn't look like it http://stackoverflow.com/questions/469357/html-text-input-allow-only-numeric-input. I guess you need to subscribe to value changes and convert to int each time. – Günter Zöchbauer Nov 01 '15 at 20:50