Angular-Schema-Form自定义组件号验证问题

时间:2015-04-13 10:17:44

标签: angularjs angular-schema-form

我创建了一个自定义组件,允许用户为基于数字的搜索选择数学运算符。除了验证之外,它的工作正常。我在下面列出了截图,以显示我的意思,并且也显示了模型的相关部分。

如果我输入数字或非数字,则验证如下。

Validation as expected

如果我输入一个数字,虽然它没有显示错误,但它没有显示绿色突出显示:

Valiation right although no green highlight

然后,如果我删除它,那么它显示空错误:

enter image description here

其他数字字段不会像我预期的那样从模型中删除,而是设置为null,这在验证通过时很好。但在这里,它不是。我注意到它没有被添加到$$值$$ ['值'],除非它是一个数字,而在正常数字字段的情况下,它是' s当null时也添加。

任何人都可以建议为什么会发生这种情况如何解决这个问题?

注意:我也没有看到ngForm下列出的这些自定义组件?不确定是否相关 - 也许,因为我不能手动设置原始...

enter image description here

编辑:根据要求,这是我的operators.html模板文件:

<div class="form-group {{form.htmlClass}}" ng-class="{'has-error': hasError()}">

  <div style="height: 45px;!important">

    <label class="control-label" ng-show="showTitle()">{{form.title}}</label>

    <div ng-class="{'input-group': (form.fieldAddonLeft || form.fieldAddonRight)}">
    <span ng-if="form.fieldAddonLeft"
          class="input-group-addon"
          ng-bind-html="form.fieldAddonLeft"></span>

      <input style="float: right; width: 75%; background-color: white; " ng-show="form.key"
             type="number"
             class="form-control"
             schema-validate="form"
             ng-model="$$value$$.value"/>

      <select ng-model="$$value$$.operator" style="float: left; width: 25%;" class="form-control"
              ng-options="operator as operator.label for operator in $parent.$parent.$parent.mappingUsedByDropdown[form.title]">
      </select>

    <span ng-if="form.fieldAddonRight"
          class="input-group-addon"
          ng-bind-html="form.fieldAddonRight"></span>

    </div>
  </div>

  <span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>
</div>

0 个答案:

没有答案
相关问题