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>

最新文章

  1. AsyncTask异步上传文本到服务器
  2. winform(三)——更换主窗体例子
  3. git 创建远程分支和删除 master 分支
  4. 通过inflate获取布局,设置layoutparams无效
  5. ArcGIS百米网格自动生成
  6. mysql导出查询结果到csv方法
  7. Pull解析xml
  8. JavaWeb之 JSP:内置对象,EL表达式,JSP标签基础
  9. hdu 1028 Ignatius and the Princess III
  10. BZOJ 4291: [PA2015]Kieszonkowe 水题
  11. js事件冒泡和事件委托
  12. 只允许输入数字的TextBox控件
  13. [OJ] Matrix Zigzag Traversal
  14. Hard 计算0到n之间2的个数 @CareerCup
  15. 引用(ajaxfileupload.js) ajaxfileupload.js报这错jQuery.handleError is not a function
  16. 面试题-浅谈JavaScript中的This指向问题
  17. Tomcat使用
  18. 【C/C++】Rotate Array
  19. MXNET:权重衰减-gluon实现
  20. springboot报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

热门文章

  1. 【转】Jmeter笔记:响应断言详解
  2. java代码用户界面网格布局GridLayout.划分为格子区域
  3. 安装ElasticSearch客户端Kibana
  4. thinkphp中的volist标签
  5. ANSI与Unicode的转换
  6. 海外开发者推荐:10个顶级2D游戏资源站
  7. Linux学习笔记 -- 为 Shell 传递参数
  8. string的深入理解
  9. Objective-C入门&amp;nbsp;简介Cocoa框架
  10. js弹出窗口