Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度用户界面提前类型已更改_Javascript_Angularjs_Angularjs Directive_Angular Ui - Fatal编程技术网

Javascript 角度用户界面提前类型已更改

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

我前面有一个奇怪的情况。由于某种原因,当结果出现时,ng模型被更改为结果的第一个结果。这对我来说是个问题,因为我有一个onenter事件,在这个事件中,我需要使用来自输入的值

以下是HTML:

<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});
        };