I have a weird issue with AngularJS and the number input. The default value will be populated for a second and then the default number disappears. Tried on FX and Chrome.
The data returned from the server is:
{
"name":"Rodolfo Heller",
"desc":"Et ullam autem iure. Facere non fuga sit. Dolorum reprehenderit voluptatem vero rem at in.",
"sell":"44.44",
"image":"xxxx",
"id":"1",
"quantity":"1"
}
I also have an ng-init="product.quantity=1" on the number input, yet the number 1 flashes then disappears.
<input type='number' min="1" step="1" class='form-control' ng-model="product.quantity" ng-init="product.quantity=1">
Any ideas why the default value disappears?
Thanks.
may be the issue with your datatypes return from the server,
{
desc: "Et ullam autem iure. Facere non fuga sit. Dolorum reprehenderit voluptatem vero rem at in."
id: "1"
image: "hidden"
name: "Rodolfo Heller"
quantity: "1" // String value for quantity
sell: "44.44"
}
your assign quantity in to a number input, But the the server sends the quantity as a string, if u cast the datatype to int from the server, or change number input to a text it will work.
so if you go with int then the data should be like,
{
desc: "Et ullam autem iure. Facere non fuga sit. Dolorum reprehenderit voluptatem vero rem at in."
id: "1"
image: "hidden"
name: "Rodolfo Heller"
quantity: 1 // int
sell: "44.44"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With