Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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
Angular 在数据绑定之前触发模糊_Angular_Firefox - Fatal编程技术网

Angular 在数据绑定之前触发模糊

Angular 在数据绑定之前触发模糊,angular,firefox,Angular,Firefox,我有一个角度,提供了一个模糊函数的日期。在Chrome(v62)中,它可以正常工作,但似乎不能与Firefox(57)一起工作 //html <input #expirationDate type="date" max="2999-12-31" class="form-control" name="ChargeExpirationDate" [ngModel]="charge.ExpirationDate" (blur)="editCharge(charge, 'ExpirationDa

我有一个角度,提供了一个模糊函数的日期。在Chrome(v62)中,它可以正常工作,但似乎不能与Firefox(57)一起工作

//html

<input #expirationDate type="date"  max="2999-12-31" class="form-control" name="ChargeExpirationDate" [ngModel]="charge.ExpirationDate" (blur)="editCharge(charge, 'ExpirationDate', expirationDate.value)"/>
如果你输入一个日期,输入的内容就会失去焦点

  • 在Chrome中:函数被调用,
    newValue
    包含一个日期字符串

  • 在Firefox中:函数启动,但
    newValue
    设置为
    “”
    。更奇怪的是,
    console.log(charge)的结果
    将实际包含字符串,但仅在
    editCharge
    函数完成后观察


有没有办法在Firefox中的模糊事件发生之前正确设置
newValue
?我不想使用
ngModelChange
,因为当我们试图用它在Chrome中输入日期时,我们注意到了一些不寻常的行为

与注释中一样,您应该使用
focusout
事件,而不是
blur

<input #expirationDate type="date"  
        class="form-control"
        max="2999-12-31"
        name="ChargeExpirationDate"
        [ngModel]="charge.ExpirationDate" 
        (focusout)="editCharge(charge, 'ExpirationDate', expirationDate.value)"/>


尝试
focusout
似乎已经解决的事件谢谢!这样做会有什么后果吗?我不完全清楚那是什么意思。哪一部分不清楚?请不要介意。我有点担心这个评论:“……这个事件和模糊之间的主要区别是后者不冒泡。”但我查了一下,我认为它不会对我的应用程序产生负面影响。所以你的问题解决了,对吗?
<input #expirationDate type="date"  
        class="form-control"
        max="2999-12-31"
        name="ChargeExpirationDate"
        [ngModel]="charge.ExpirationDate" 
        (focusout)="editCharge(charge, 'ExpirationDate', expirationDate.value)"/>