Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 ng blur仅在文本框内单击时有效_Javascript_Angularjs - Fatal编程技术网

Javascript ng blur仅在文本框内单击时有效

Javascript ng blur仅在文本框内单击时有效,javascript,angularjs,Javascript,Angularjs,我有一个文本框,可以在其中写入值。如果我删除了该值,并且没有在适当的位置写入任何内容,我希望当我单击其他位置时,该值在文本框中“返回” 有些东西是有效的,但并不完全是应该的 HTML部分: <input type="number" ng-blur="$ctrl.blur('max')" ng-change="$ctrl.updateY('max')" ng-model-options="{debounce: 500}" ng-model="$ctrl.max"> 现在,如果我

我有一个文本框,可以在其中写入值。如果我删除了该值,并且没有在适当的位置写入任何内容,我希望当我单击其他位置时,该值在文本框中“返回”

有些东西是有效的,但并不完全是应该的

HTML部分:

<input type="number" ng-blur="$ctrl.blur('max')" 
ng-change="$ctrl.updateY('max')" ng-model-options="{debounce: 500}" 
ng-model="$ctrl.max">

现在,如果我删除文本框的值并单击屏幕上的其他位置,则该值不会写回文本框

但如果在删除文本框后单击文本框,则会将其写回。我想让它被重新写入,即使我点击文本框之外的任何地方

这可能吗?

我也可以看到这种“奇怪”的行为,因为它只是偶尔发生,而不是一直发生。 要解决此问题,请删除

ng-model-options="{debounce: 500}" 

它会起作用的

很好用:我明白了,它看起来和我的一样,在plunker中也很好用。但出于一个我不知道的原因,在我的项目中,只有在删除文本后单击文本框,它才会起作用
updateY(which) {
    if(which === 'max') {
        if(this.max) {
            this.maxValue = this.max;
        }
    }
const maxNumber = Number(this.maxValue);
this.lineView.chart.axis.range({max: {y: maxNumber}, min: {y: maxNumber-100}});
}
ng-model-options="{debounce: 500}"