ExpressionChangedAfterItHasBeenCheckedError - Expression has changed after it was checked

简介: Expression has changed after it was checked
export class BankAccount implements OnChanges{
  ngOnChanges(changes: SimpleChanges): void {
    /*console.log('ngOnChanges triggered: ' + changes.bankName.currentValue + ' previous value: ' + changes.bankName.previousValue);*/
  }
  // This property is bound using its original name.
  /*
  @Input()
  set bankName(newName) {
    console.log('bankName new value set: ' + newName);
  }*/
  @Input()
  bankName:string;
  // this property value is bound to a different property name
  // when this component is instantiated in a template.
  @Input('account-id') 
  id: string;
  // this property is not bound, and is not automatically updated by Angular
  normalizedBankName: string;
}
@Component({
  selector: 'app',
  template: `
    <bank-account [bankName]="bankName" account-id="4747"></bank-account>
  `
})
export class App implements OnInit, AfterViewInit{
  _bankName = 'Jerry';
  ngAfterViewInit(): void {
    this._bankName = 'Jerry2';
  }
  get bankName(){
    return this._bankName;
  }
  ngOnInit(): void {
  }
}

image.png

image.png

image.png


相关文章
|
2月前
|
JavaScript 前端开发
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
这篇文章解释了在HTML文档中因JavaScript代码在页面元素加载之前执行导致的"Cannot set properties of null (setting ‘onclick’)"错误,并提供了将JavaScript代码置于`<body>`标签内或使用`window.onload`事件确保DOM完全加载后再绑定事件处理器的解决办法。
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
|
2月前
|
CDN
Iconfont——Error: <path> attribute d: Expected number, "MNaNNaNaNaNNaNNaN…".
Iconfont——Error: <path> attribute d: Expected number, "MNaNNaNaNaNNaNNaN…".
30 0
|
5月前
|
JavaScript 程序员 Swift
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
The compiler is unable to type-check this expression in reasonable time; try breaking up the express
61 0
TypeError: custom() got an unexpected keyword argument ‘path‘
TypeError: custom() got an unexpected keyword argument ‘path‘
142 0
解决报错之 - error Identifier ‘attr_id‘ is not in camel case camelcase
解决报错之 - error Identifier ‘attr_id‘ is not in camel case camelcase
419 0
解决报错之 - error Identifier ‘attr_id‘ is not in camel case camelcase
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
|
C语言
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
140 0
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
解决办法:Type safety: The expression of type List needs unchecked conversion to conform
308 0
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
455 0