Javascript 角度用户界面提前类型已更改
我前面有一个奇怪的情况。由于某种原因,当结果出现时,ng模型被更改为结果的第一个结果。这对我来说是个问题,因为我有一个onenter事件,在这个事件中,我需要使用来自输入的值 以下是HTML:Javascript 角度用户界面提前类型已更改,javascript,angularjs,angularjs-directive,angular-ui,Javascript,Angularjs,Angularjs Directive,Angular Ui,我前面有一个奇怪的情况。由于某种原因,当结果出现时,ng模型被更改为结果的第一个结果。这对我来说是个问题,因为我有一个onenter事件,在这个事件中,我需要使用来自输入的值 以下是HTML: <input type="search" dropdown-toggle class="form-control input--search" pw-enter="search
<input type="search" dropdown-toggle
class="form-control input--search"
pw-enter="searchEnter()"
placeholder="Search"
typeahead="result.text for result in getSearchResult($viewValue)"
ng-model="search.query"
typeahead-template-url="views/search-custom.html"
typeahead-wait-ms="300"
typeahead-focus-first="false"
>
正如您所看到的,这是搜索实现,在输入时我需要使用搜索到的值($scope.search.query)进行高级搜索,但由于某种原因,该值被更改为,首先生成我提到的结果
如何解决此问题或是否有任何解决方法?有“typeahead focus first(默认值:true):是否应在键入时自动聚焦第一个匹配项?”在中,假值对您的情况有帮助吗?还有,为什么不使用“typeahead on select($item,$model,$label)”进行高级搜索,而使用自定义指令“pCenter”?
$scope.getSearchResult = function (query) {
return SearchService.getResults(query);
};
$scope.searchEnter = function(){
$location.path('/advance-search').search({query : $scope.search.query});
};