1

When I set initial value of variable to "0", then NumericTextBox field cant show this value.

Code:

<div ng-app="app">
    <div ng-controller="MyCtrl">
        <input type="text" ng-model="value" kendo-numeric-text-box>
            <br>
        <input type="text" ng-model="value">
    </div>
</div>

JS:

angular.module('app', ['kendo.directives']);
function MyCtrl($scope) {
    $scope.value=0;
};

In jsfiddle you can see that simple text field displays zero value, but kendo NumericTextBox is empty. But if you type zero again in simple text field, then zero will be in kendo field too. I think this is a bug, how to get around this problem?

OnaBai
  • 40,767
  • 6
  • 96
  • 125
Dmitry Skryabin
  • 1,584
  • 2
  • 10
  • 15

1 Answers1

0

Well, if it is a bug, you can either ask the maintainer of angular-kendo to fix it, or you can fix it yourself. It's a relatively simple fix, I think, because the link function doesn't distinguish between model values 0 and undefined. So you'd need to make sure the widget's value method is only called with null if the value is actually null or undefined:

if (typeof ngModel.$viewValue !== 'undefined') {
    widget.value(ngModel.$viewValue);
} else {
    widget.value(null);
}

Here's a demo with a fixed version (links to a fork of angular-kendo, mind you).

Lars Höppner
  • 18,252
  • 2
  • 45
  • 73
  • Thank you! Will you make a pull request, or I must to fix this in my fork and then make a pull request? – Dmitry Skryabin Jan 13 '14 at 04:22
  • actually, it looks like this was [already fixed](https://github.com/kendo-labs/angular-kendo/issues/124), even though only in the angular-kendo.js file in the root – Lars Höppner Jan 13 '14 at 10:41