Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number field not displaying data #10

Open
rpapeters opened this issue Mar 12, 2015 · 1 comment
Open

Number field not displaying data #10

rpapeters opened this issue Mar 12, 2015 · 1 comment

Comments

@rpapeters
Copy link

When initially loading a form with a Number field then the value of this field is not shown, while other fields do show their data. However after editing the field, the corresponding property is updated meaning the binding should be ok.

@SPeeSimon
Copy link

This seems to be related to Angular 1.2.
I have created a workaround with the help of http://blog.jdriven.com/2013/09/how-angularjs-directives-renders-model-value-and-parses-user-input/

angular.module('fg').directive('fgInputNumber', function() {
  return {
   require: 'ngModel',
   link: function(scope, element, attr, ctrl) {
      ctrl.$formatters.push(function(inputValue) {
          if (typeof inputValue == 'number') {
              ctrl.$setValidity('fgInputNumber', true);
              return inputValue.toString();
          }
          if( angular.isNumber(inputValue) ){
              ctrl.$setValidity('fgInputNumber', true);
          }
          return inputValue;
      });
   }
 };
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants