We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html
<button (click)="a()">1233</button>
ts
import { KeyValueChanges, KeyValueDiffer, KeyValueDiffers } from '@angular/core'; export class Customer { firstName: string; favoriteColor: string; } export class xx { private customerDiffer: KeyValueDiffer<string, any>; private customer: Customer; constructor( private differs: KeyValueDiffers ) { this.customer = new Customer(); this.customerDiffer = this.differs.find(this.customer).create(); } customerChanged(changes: KeyValueChanges<string, any>) { console.log('changes'); /* If you want to see details then use changes.forEachRemovedItem((record) => ...); changes.forEachAddedItem((record) => ...); changes.forEachChangedItem((record) => ...); */ } ngDoCheck(): void { const changes = this.customerDiffer.diff(this.customer); if (changes) { this.customerChanged(changes); } } a(){ this.customer.firstName+= "2"; } }
ngModelChange
<input type="text" (ngModelChange)="doSomething($event)" [ngModel]="customer.firstName">
doSomething(event) { console.log(event); // logs model value }
valueChanges
ngOnInit() { this.form = this.fb.group({ // xxx }); } ngAfterViewInit(): void { this.form.valueChanges.subscribe((change) => { console.log(change) }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
KeyValueChanges 方法
html
ts
使用
ngModelChange
监听ts
如在动态表单中可使用
valueChanges
监听The text was updated successfully, but these errors were encountered: