事件不会从角度js

时间:2017-07-15 10:51:47

标签: javascript jquery asp.net angularjs kendo-combobox

我想使用angular js指令自定义kendo组合框中的数据。该代码给出了以下内容:

HTML页面: -

<input name="Type"  kendo-combo-box k-filter="'contains'"
  k-data-value-field="'ID'" k-data-text-field="'Description'"
  k-data-source="TblABC" xgen-valid-combo data-ng-model="TypeID" id="NarType" />

指令代码: -

define(['app'], function (app) {
    app.register.directive('xgenValidCombo', ['$timeout', '$parse', function ($timeout, $parse) {
        return {
            restrict: 'A',
            require: 'ngModel',
            link: function (scope, element, attrs, ctrl) {

此事件名为

                element.on("blur", function (e) { --- **this event called**
                    if (ctrl.$$rawModelValue != null && ctrl.$$rawModelValue != '' && element[0][0] != null
                        && !(parseInt(ctrl.$$rawModelValue) > 0) && parseInt(element[0][0].value) > 0) {
                        ctrl.$setViewValue(element[0][0].value);
                        ctrl.$render();
                        return;
                    }
                    else if ((element.val() && element.getKendoComboBox().selectedIndex === -1)) {
                        ctrl.$setViewValue("");
                        ctrl.$render();
                    }
                });

此事件未被调用

                element.on("focus", function (e) {
                    if (ctrl.$$rawModelValue != null && ctrl.$$rawModelValue != '' && element[0][0] != null
                        && !(parseInt(ctrl.$$rawModelValue) > 0) && parseInt(element[0][0].value) > 0) {
                        // logic for customize data
                    }
                });
                var v1 = scope.$on('$destroy', function () {
                    element.off("blur");
                    element.off("focus");
                    v1();
                });
            }
        }
    }]);
    });

为什么在关注此组合框时未调用焦点事件?

0 个答案:

没有答案