如何用k-ng模型制作字段?

时间:2015-07-09 20:44:26

标签: angularjs kendo-ui

如果我在Angularjs验证不需要字段的字段上使用k-ng-model我有验证问题,用户可以提交表单,因此在代码字段下面是必需的,即使我没有选择值,用户仍然可以提交表单。任何想法如何解决?

main.html

<div class="row">
   <div class="form-group col-md-12">
     <label for="themesList" class="required col-md-4">Themes:</label>
        <div class="col-md-8">
         <select class="multiselect" kendo-multi-select="themes"
                                k-options="challengThemesOptions" data-text-field="'text'"
                                data-value-field="'id'" name="themesList"
                                k-ng-model="challengesDTO.themesKyList" required
                                id="themesList"></select>
          <p class="text-danger" ng-show="addChallengeForm.themesList.$touched && ddChallengeForm.themesList.$error.required">Theme(s) is required</p>
        </div>
    </div>
  </div>

1 个答案:

答案 0 :(得分:3)

您可以将ng-model与k-ng-model一起使用,尝试将ng-model分配给单独的变量并使用ng-required。

<select class="multiselect" kendo-multi-select="themes"
                            k-options="challengThemesOptions" data-text-field="'text'"
                            data-value-field="'id'" name="themesList"
                            k-ng-model="challengesDTO.themesKyList" ng-model="challengesDTO.themesKyListValue" ng-required
                            id="themesList"></select>