Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am tearing my hair out over this one. I'm getting the following error in the console from Angular:

The specified value "{{vm.data.tax.amount}}" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+.\d+|.\d+)([eE][-+]?\d+)?

I am porting an existing Angular 1.5 UI from a Ruby based API to a .NET Core API. Here is the controller method that is returning the response:

public JsonResult Get(int id)
    {
        TaxWrapper taxWrapper = new TaxWrapper()
        {
            tax = new Tax()
            {
                id = id,
                amount = 123.45m,
                reported_month = "January",
                reported_year = "2016",
            }
        };
        return Json(taxWrapper, jsonHideNulls);
    }

Here is the angular component code that is causing the console error:

      md-input-container.md-block(flex-gt-sm)
    label Amount
    input(ng-model="vm.data.tax.amount", type="number", step="0.01", value="{{vm.data.tax.amount}}")
    .errors(ng-if="vm.errors['amount']") {{vm.errors['amount'][0]}}

And here is the JSON response from the controller:

{"tax":{"id":1,"amount":123.45,"reported_month":"January","reported_year":"2016"}}

What's odd is that the amount displays in the browser just fine and the step buttons work, it just throws this error. Any thoughts?

share|improve this question
    
What happens when you remove the value attribute and just let it bind the model? – Markus yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.