Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.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 在safari浏览器中的“粘贴”命令上未更新ng模型_Javascript_Angularjs - Fatal编程技术网

Javascript 在safari浏览器中的“粘贴”命令上未更新ng模型

Javascript 在safari浏览器中的“粘贴”命令上未更新ng模型,javascript,angularjs,Javascript,Angularjs,我有一个搜索文本框,用于搜索文本。如果我一个字符一个字符地添加文本,它工作正常,但是当我将数据直接粘贴到文本框中时,我的ng模型没有得到更新。此问题仅适用于safari浏览器 这是我的html <div class="div-input pull-left" ng-submit="submitFilterForm()" ng-class="{ 'filter-dropdown-adjustment' : showFilterState() }"> <in

我有一个搜索文本框,用于搜索文本。如果我一个字符一个字符地添加文本,它工作正常,但是当我将数据直接粘贴到文本框中时,我的ng模型没有得到更新。此问题仅适用于safari浏览器

这是我的html

<div class="div-input pull-left" ng-submit="submitFilterForm()" ng-class="{ 'filter-dropdown-adjustment' : showFilterState() }">
            <input type="text" class="filter-input" ng-model="query" my-
     enter="submitFilterForm()" auto-focus />
        </div>
}))

这是我的js文件,其中包含文本框ng模型上的$watch函数

       $scope.$watch("query", function(name) {
            $scope.validationError = false;
            console.log("value of query is", name);
            filterStateService.updateSearchQuery(name);
        });

看看这个。我使用了
ng粘贴


var-app=angular.module('myApp',[]);
应用控制器('mainController',功能($scope){
$scope.handlePaste=函数(e){
setTimeout(函数(){
$scope.query=e.target.value;
console.log(例如target.value,“val”)
},10)
}
});
{{query}

因为粘贴不是<代码>键下<代码>或<代码>键按下<代码>,尝试使用<代码>元素。绑定(“输入”)<代码> Hy@ AsWorx,请考虑使用EntEngt中的“更改”。绑定如下:代码>元素。绑定(“更改键按下键””,函数(事件){
。我希望它会起作用。它没有起作用。嘿,我尝试了你的解决方案,它在IE和chrome中工作得很好,但在safari中,查询字段的值没有定义。你在控制台中得到了什么?$scope.handlePaste=function(val){console.log(“M in handlePaste”,val);$scope.query=val;};值在safari中为未定义值在safari中为未定义值browser@ashworx为什么不使用更新的anser apprach.
$scope.handlePaste=function(e){$scope.query=e.target.value;console.log(e.target.value,“val”)}
       $scope.$watch("query", function(name) {
            $scope.validationError = false;
            console.log("value of query is", name);
            filterStateService.updateSearchQuery(name);
        });