angular Docheck
2024-08-24 23:57:23
import { Component, OnInit, Input, OnChanges, SimpleChanges, DoCheck } from '@angular/core'; @Component({
selector: 'app-child',
templateUrl: './child.component.html',
styleUrls: ['./child.component.css']
})
export class ChildComponent implements OnInit, OnChanges, DoCheck { @Input()
greeting: string; @Input()
user: {}; message = 'hello'; constructor() { } ngOnInit() {
} ngOnChanges(changes: SimpleChanges): void {
console.log(JSON.stringify(changes, null, ));
} ngDoCheck(): void {
console.log('子组件Docheck');
} }
<div>子组件</div>
<p>问候语{{greeting}}</p>
<p>用户{{user.name}}</p>
<input [(ngModel)]='message'>
import { Component, DoCheck } from '@angular/core'; @Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements DoCheck { greeting = 'nihao';
user: { name: string } = { name: 'cys' }; ngDoCheck(): void {
console.log('父组件Docheck');
}
}
<input [(ngModel)]="greeting" type="text">
<input [(ngModel)]="user.name" type="text">
<app-child [greeting]="greeting" [user]="user"></app-child>
最新文章
- AsyncTask异步上传文本到服务器
- winform(三)——更换主窗体例子
- git 创建远程分支和删除 master 分支
- 通过inflate获取布局,设置layoutparams无效
- ArcGIS百米网格自动生成
- mysql导出查询结果到csv方法
- Pull解析xml
- JavaWeb之 JSP:内置对象,EL表达式,JSP标签基础
- hdu 1028 Ignatius and the Princess III
- BZOJ 4291: [PA2015]Kieszonkowe 水题
- js事件冒泡和事件委托
- 只允许输入数字的TextBox控件
- [OJ] Matrix Zigzag Traversal
- Hard 计算0到n之间2的个数 @CareerCup
- 引用(ajaxfileupload.js) ajaxfileupload.js报这错jQuery.handleError is not a function
- 面试题-浅谈JavaScript中的This指向问题
- Tomcat使用
- 【C/C++】Rotate Array
- MXNET:权重衰减-gluon实现
- springboot报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean