Skip to content

type="number" passes String as argument #4014

Closed

Description

@rightisleft

When setting the field of:

num bZip;

From:

        <div class="form-group">
            <label for="billing_zip">Zip</label>
            <input type="number" id="billing_zip" [(ng-model)]="dto.bZip" class="form-control" [required]="true"/>
        </div>

EXCEPTION: Error during evaluation of "ngModel"
ORIGINAL EXCEPTION: type 'String' is not a subtype of type 'num' of 'value'.
ORIGINAL STACKTRACE:

Using Angular Dart alpha 35

Fix: if i set the field to String bZip on the DTO object

name: 'tickets'
version: 0.0.1
description: A ticket commerce application
author: Jack Murphy [email protected]
homepage: https://www.rightisleft.com
environment:
  sdk: '>=1.0.0 <2.0.0'
dependencies:
#Server Dependencies
  json_object: "1.0.19"
  mongo_dart: "0.1.46"
  connection_pool: "0.1.0+2"
  dartson: "0.2.4"
  guinness: "0.1.17"
  shelf: '>=0.6.2 <0.7.0'
  shelf_static: "0.2.2"
  shelf_route: "0.14.0"
#Client Dependencies
  bootjack: "0.6.5"
  browser: ">=0.10.0+2 <0.11.0"
  sass: "0.4.2"
  angular2: "2.0.0-alpha.35"
transformers:
- dartson
- sass
- angular2:
    entry_points:
        - web/main.dart
    reflection_entry_points:
        - web/main.dart
- $dart2js:
    minify: true
    commandLineOptions:
    - --dump-info
    - --show-package-warnings
    - --trust-type-annotations
    - --trust-primitives

Activity

  1. IAPark commented on Sep 11, 2015

    @IAPark
    Contributor

    I don't seem to get an error in TypeScript, but it doesn't convert for me which is what I expected it to do. Would there be interest in converting to an int/number in cases where the type equals number? Or is this added complication and should be handled by other means

  2. rightisleft commented on Sep 14, 2015

    @rightisleft
    Author

    I would assume that if the type is number - then the value exposed to the model would also be a numeric value.

    Dart throws an error as its a type mismatch - converting the variable type to String fixes the symptom, but it should not be String ....

  3. added a commit that references this issue on Oct 15, 2015
    d58eb13
  4. zakton5 commented on Apr 6, 2016

    @zakton5

    I have the latest beta version and I am still seeing this issue. A input with type=number using ngModel is returning a string to the model instead of a number. Any progress on this?

  5. gamebox commented on Apr 21, 2016

    @gamebox

    @RemnantArcher Do you have a small plunk to verify this is till true as of Beta 15? I noticed that the tests don't cover the ng-model use-case, though on the surface don't see a reason why it should fail there.

  6. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions