简体   繁体   English

当使用浏览器后退按钮导航到页面时,角度绑定在Chrome上的应用不正确

[英]Angular bindings applied incorrectly on Chrome when browser back button is used to navigate to page

Any ideas on why this might happen? 为什么会发生这种情况的任何想法? I've got several textboxes that are generated inside an ngFor: 我在ngFor内部生成了几个文本框:

    <tr *ngFor="let tableRow of lineItems; trackBy:trackByIndex; let rowIndex = index; ">     
      <td class="psavingsSmallerGridCell"><input currencyMask [(ngModel)]="tableRow.existingCost" [attr.disabled] = "shouldExistingChargeBeReadOnly(tableRow)"/></td>
      <td class="psavingsSmallerGridCell"><input currencyMask [(ngModel)]="tableRow.projectedCost" /></td>
      <td class="psavingsSmallerGridCell"><input currencyMask [ngModel]="tableRow.actualCost" disabled /></td>

I've console.logged to verify the lineItems array from the model is accurate, but for whatever reason when using the back button in Chrome (Version 66.0.3359.181 (Official Build) 64-bit), the values bound to the inputs get all sorts of jacked up. 我已经用console.logged验证了模型中的lineItems数组是正确的,但是出于某种原因,当在Chrome(版本66.0.3359.181(正式版本)64位)中使用“后退”按钮时,绑定到输入的值将全部有点烦。 Of the browsers I've tried, so far only Chrome has this behavior. 在我尝试过的浏览器中,到目前为止,只有Chrome浏览器具有此行为。

Image of messed up rendering 混乱的图像渲染

I did try removing the currencyMask 3rd party directive to eliminate that as a source of the problem. 我确实尝试删除了currencyMask 3rd party指令,以消除该问题的根源。

Inspecting the DOM with dev tools shows the ng-reflect-model attribute on the messed up boxes has the right value assigned, it's just the input text value itself is wrong. 使用开发人员工具检查DOM后,会看到混乱框中的ng-reflect-model属性分配了正确的值,只是输入文本值本身是错误的。

This ended up being less to do with Angular and more to do with Chrome's handling of dynamic forms. 最终,这与Angular无关,而与Chrome对动态表单的处理更多。 Setting autocomplete=off on the form element fixed the issue. 在表单元素上设置autocomplete = off可解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM