gpt4 book ai didi

angular - pKeyFIlter : NG8007: The property and event halves of the two-way binding 'ngModel' are not bound to the same target

转载 作者:行者123 更新时间:2023-12-04 14:52:49 41 4
gpt4 key购买 nike

我已经使用 Primeng 控件将我的 Angular 11 项目更新为 Angular 12。完成后,primeng pKeyFilter 在任何使用它的地方都会抛出错误。从头开始创建一个新的 Angular 12 项目没有这个问题。升级后其他一切似乎都可以正常工作。有什么想法吗?
这是组件

import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-key',
templateUrl: './key.component.html',
styleUrls: ['./key.component.scss']
})
export class KeyComponent implements OnInit {
public myvalue: string = '';

constructor() { }

ngOnInit(): void {
}

}
这是 HTML
<input type="text" pInputText [(ngModel)]="myvalue" pKeyFilter="int"/>

<p>
<span>{{myvalue}}</span>
</p>
这是完整的错误

Error:src/app/modules/nourishment/pages/test/key/key.component.html:1:23 -error NG8007: The property and event halves of the two-way binding'ngModel' are not bound to the same target.Find more at https://angular.io/guide/two-way-binding#how-two-way-binding-works

1 <input type="text" [(ngModel)]="myvalue" pKeyFilter="int"/>~~~~~~~

node_modules/@angular/forms/forms.d.ts:3297:223297 export declare class NgModel extends NgControl implements OnChanges, OnDestroy {~~~~~~~The property half of the binding is to the 'NgModel' component.

node_modules/primeng/keyfilter/keyfilter.d.ts:6:226 export declare class KeyFilter implements Validator {~~~~~~~~~The event half of the binding is to the 'KeyFilter' component.

src/app/modules/nourishment/pages/test/key/key.component.ts:5:165 templateUrl: './key.component.html',~~~~~~~~~~~~~~~~~~~~~~Error occurs in the template of component KeyComponent.


我了解错误背后的基础知识,但我无法弄清楚是什么触发了它。我在父模块中导入了质数 InputModule 和 KeyFilterModule 以及 FormsModule 。同样,这一切在升级之前都有效。 https://www.primefaces.org/primeng/showcase/#/keyfilter

最佳答案

我只是先更改了 [(ngModel)] 的顺序,最后更改了 [pKeyFilter] 的顺序
来自 :

<input type="text"  pInputText [pKeyFilter]="'money'" [(ngModel)]="tare" >
:
<input type="text"  pInputText  [(ngModel)]="tare" [pKeyFilter]="'money'" >
它的工作良好

关于angular - pKeyFIlter : NG8007: The property and event halves of the two-way binding 'ngModel' are not bound to the same target,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68764954/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com