Typeahead搜索结果与验证错位

时间:2014-11-08 10:48:58

标签: angularjs angular-ui-bootstrap angular-ui-typeahead

我在AngularJS应用程序中使用基于jQuery验证的验证插件(它建立在jQuery库之上)。

当我使用ui bootstrap Typeahead进行验证时,搜索结果会放错位置。

Plunkr:

http://plnkr.co/edit/ZYP58GxITghkTqE7PNHy

HTML(help.html)

<div class="form-group">
        <label for="category">Category "{{formData.category}}"</label>
          <input class="form-control" type="text" name="category" id="category" placeholder="Search..." ng-model="formData.category" typeahead="obj.name for obj in getCdOnCat($viewValue)" typeahead-editable="false" typeahead-loading="loadingLocations" required>
    </div>

JS(script.js) - HelpController

//Typeahead: Category Search
    $scope.getCdOnCat = function (searchVal) {
        return dataFactory.getCdOnCategory(searchVal).then(function (response) {
            return response.data.categories;
        }, function (error) {
            console.log('Error: dataFactory.getCdOnCategory');
        });
    };

    $scope.$watch('formData.category', function (value) {
        if (value === "No matching categories") {
            $scope.formData.category = "";
        }
    });

0 个答案:

没有答案